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コミット手順覚え書き

Last updated at Posted at 2025-09-14

毎回GitHubにコミットするとき、手順がわからなくなるのでまとめてみました。
参考になれば嬉しいです。

前提条件

  • Gitをインストール・初期設定済み
  • GitHubアカウントがある
  • GitHubでリモートリポジトリ作成済み
  • コマンドプロンプトを使用してコミットする

コミット(初回)

  1. コマンドプロンプトを開く
  2. cd 【コミットしたいファイルがあるディレクトリパス】 をコマンドプロンプトに入力
    ※初期設定だとcd "C:\Users\ユーザ名"になっていて、そのままコミットすると人に見られたくない重要なファイルも全部ステージングされてしまうよ!
    必ずコミットしたいファイルがあるフォルダに移動してからgit init してね!
  3. git init
  4. git remote add origin 【GitHubのリモートリポジトリURL】
    ★git remote -vしてすでにoriginが登録されていたらする必要なし
  5. git add .
  6. git commit -m"任意のコミットメッセージ"
    ★who you areを聞かれるときは以下を入力してその後再度コミットする
     git config user.email 【GitHubのメールアドレス】
     git config user.name 【GitHubのユーザ名】(順不同)
  7. git push -u origin main

コミット(2回目以降)

  1. コマンドプロンプトのcdで任意のフォルダ内にいることを確認
  2. git branchでmainにいることを確認
     ★masterにいる場合
     git config --global init.defaultBranch main または
     git branch -m master main
  3. git add .
  4. git commit -m"任意のコミットメッセージ"
     ★who you areを聞かれるときは以下を入力してその後再度コミットする
     git config user.email 【GitHubのメールアドレス】
     git config user.name 【GitHubのアカウント名】(順不同)
  5. git push

補足

コミット時に毎回メールアドレスとユーザ名を聞かれるのが面倒な場合、
以下の記事を参考にするとよいと思います。

Githubで毎回パスワード聞かれてうるさいと思ったらssh接続の設定を行う

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?