0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Github】アプリをGithubにプッシュするまでの手順

Last updated at Posted at 2025-01-05

Githubへプッシュ手順について

Githubのアカウントは持っているものの、どうやってアプリをプッシュすればよいかを備忘録として残しておきます。

Guthubにプッシュするまでの手順

Github公式サイトにアクセスする

トップページはこのような画面が出てきます。
Github公式サイト.png

サインインを求められるのでアカウント情報を入力します。
Githubサインイン.png

新規のリポジトリを作成します(赤枠の箇所)
リポジトリ作成.png

つぎにやることは、
①リポジトリ名の入力
②PublicまたはPrivateの設定
③README.mdのチェックを入れなくて※こちらはチェックしなくてよいです

リポジトリ作成2.png

リポジトリの作成が完了すると下記のが表示されます。

リポジトリ作成完了.png

さっそくやってみる。

今回は、ReactとLaravelで作ったサンプルプロジェクトをプッシュしてみたいと思います。

リポジトリの作成

まず、git initコマンドでローカルにリポジトリの作成をします。

git init

github1.png

すると、エクスプローラには、「.git」というリポジトリが作成されます。

github2.png

ローカルリポジトリにすべてのファイルを加える

ローカルリポジトリにすべてのファイルを加えるためgit addコマンドを実行しましょう。

git add .

すると、こんなかんじにコンソール画面にずらずらーっと出てきます。

(コンソール画面)
warning: in the working copy of 'Dir Maker繝・ぅ繝ャ繧ッ繝医Μ.txt', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/eslint.config.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/index.html', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/package-lock.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/package.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/postcss.config.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/src/App.tsx', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/src/main.tsx', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'frontend/src/vite-env.d.ts', LF will be replaced by CRLF the next time Git touches it

Github公式サイトのサンプルでは、「git add README.md」と書いてありますが、このREADME.mdファイルのみをプッシュするだけです。

なので、全部のプロジェクトファイルをプッシュするには上記↑のコマンドを使いましょう。

git commitコマンドを実行する

git commitコマンドを実行してgit addで追加したファイルをcommitしましょう。

git commit -m "first commit"

するとこんな感じで、コミットされていきます。

[master (root-commit) fd7444c] first commit
 115 files changed, 16596 insertions(+)
 create mode 100644 "Dir Maker\343\203\207\343\202\243\343\203\254\343\202\257\343\203\210\343\203\252.txt"
 create mode 100644 "Put\351\200\201\344\277\241\343\201\253\343\201\244\343\201\204\343\201\246.txt"
 create mode 100644 backend/.editorconfig
 create mode 100644 backend/.env.example
 create mode 100644 backend/.gitattributes
 create mode 100644 backend/.gitignore
 create mode 100644 backend/README.md
 create mode 100644 backend/app/Console/Kernel.php
 create mode 100644 backend/app/Exceptions/Handler.php
 create mode 100644 backend/app/Http/Controllers/Controller.php
 create mode 100644 backend/app/Http/Controllers/EventController.php
 create mode 100644 backend/app/Http/Controllers/RegisterController.php
 create mode 100644 backend/app/Http/Kernel.php
 create mode 100644 backend/app/Http/Middleware/Authenticate.php
 create mode 100644 backend/app/Http/Middleware/EncryptCookies.php
 create mode 100644 backend/app/Http/Middleware/PreventRequestsDuringMaintenance.php
 create mode 100644 backend/app/Http/Middleware/RedirectIfAuthenticated.php
 create mode 100644 backend/app/Http/Middleware/TrimStrings.php
 create mode 100644 backend/app/Http/Middleware/TrustHosts.php
 create mode 100644 backend/app/Http/Middleware/TrustProxies.php
 create mode 100644 backend/app/Http/Middleware/ValidateSignature.php
 create mode 100644 backend/app/Http/Middleware/VerifyCsrfToken.php
 create mode 100644 backend/app/Models/Event.php
 create mode 100644 backend/app/Models/User.php
 create mode 100644 backend/app/Providers/AppServiceProvider.php
 create mode 100644 backend/app/Providers/AuthServiceProvider.php
 create mode 100644 backend/app/Providers/BroadcastServiceProvider.php
 create mode 100644 backend/app/Providers/EventServiceProvider.php
 create mode 100644 backend/app/Providers/RouteServiceProvider.php
 create mode 100644 backend/artisan
 create mode 100644 backend/bootstrap/app.php
 create mode 100644 backend/bootstrap/cache/.gitignore

ローカルリポジトリ内で現在のブランチ名を main に変更する

ローカルリポジトリ内で現在のブランチ名を main に強制的に変更します。

git branch -M main

リモートのリポジトリの設定を行う。

リモートのリポジトリの設定を行いましょう。

git remote add origin https://github.com/(アカウント名)/reactLaravelEventApps.git

git pushコマンドでGitHubのリポジトリにプッシュする

最後にgit pushコマンドでGitHubのリポジトリにプッシュします。

git push -u origin main

すると、下記のようにプッシュされます。

Enumerating objects: 158, done.
Counting objects: 100% (158/158), done.
Delta compression using up to 16 threads
Compressing objects: 100% (126/126), done.
Writing objects: 100% (158/158), 127.24 KiB | 3.63 MiB/s, done.
Total 158 (delta 10), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (10/10), done.
To https://github.com/(アカウント名)/reactLaravelEventApps.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

以上です。

参考サイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?