Reference

逆引きチートシート

「やりたいこと」から引けるGitコマンド集。74項目を11カテゴリに整理しました。 レッスンで詳しく学んだことを後から思い出すときに使ってください。

⚙️初期設定

Gitがインストールされているか確認
git --version
Lesson 1-2 →
名前を登録
git config --global user.name "Taro"
Lesson 1-2 →
メールアドレスを登録
git config --global user.email "you@example.com"
Lesson 1-2 →
デフォルトブランチを main に
git config --global init.defaultBranch main
Lesson 1-2 →
エディタを VS Code に
git config --global core.editor "code --wait"
Lesson 1-2 →
改行コードの自動変換(Windows)
git config --global core.autocrlf true
Lesson 3-7 →
alias を設定
git config --global alias.st status
Lesson 3-7 →
認証情報を保存
git config --global credential.helper store
Lesson 3-7 →
現在の設定を一覧で見る
git config --global --list
Lesson 3-7 →

📦リポジトリの作成・状態確認

フォルダをリポジトリに変える
git init
Lesson 1-3 →
リモートからクローン
git clone <URL>
Lesson 1-6 →
現在の状態を確認
git status
Lesson 1-3 →
簡潔に状態を確認
git status -s
Lesson 1-3 →

💾コミットを作る

1ファイルだけステージング
git add <file>
Lesson 1-4 →
すべての変更をステージング
git add .
Lesson 1-4 →
コミット(メッセージ付き)
git commit -m "メッセージ"
Lesson 1-4 →
直前のコミットを修正
git commit --amend
公開前のみ使う Lesson 2-5 →
ステージングをスキップしてコミット
git commit -am "メッセージ"
追跡中ファイルのみ Lesson 1-4 →

🔍履歴を見る・調べる

コミット履歴を見る
git log
Lesson 1-5 →
1行で簡潔に
git log --oneline
Lesson 1-5 →
グラフ付きで全ブランチ
git log --oneline --graph --all
Lesson 3-3 →
作業ツリーの差分
git diff
Lesson 1-5 →
ステージング済との差分
git diff --staged
Lesson 1-5 →
コミット間の差分
git diff <id1> <id2>
Lesson 1-5 →
特定コミットの中身
git show <id>
Lesson 3-3 →
行ごとの責任者
git blame <file>
Lesson 3-3 →
リネーム前まで履歴を追跡
git log --follow <file>
Lesson 3-3 →
作者で絞る
git log --author="Taro"
Lesson 3-3 →

🌿ブランチ操作

ブランチ一覧
git branch
Lesson 2-1 →
作成
git branch <name>
Lesson 2-1 →
切り替え
git switch <name>
Lesson 2-1 →
作って切り替え
git switch -c <name>
Lesson 2-1 →
削除(マージ済み)
git branch -d <name>
Lesson 2-1 →
強制削除
git branch -D <name>
未マージでも消える Lesson 2-1 →
リネーム
git branch -m <new>
今いるブランチをリネーム Lesson 2-1 →

🔀マージ・統合

ブランチを取り込む
git merge <branch>
取り込み先に立って実行 Lesson 2-2 →
マージを中止
git merge --abort
Lesson 2-3 →
履歴を一直線に整える
git rebase <branch>
公開済みには使わない Lesson 3-5 →
rebaseを中止
git rebase --abort
Lesson 3-5 →
1コミットだけ取り込む
git cherry-pick <id>
Lesson 3-5 →

取り消す・戻す

編集を捨てる(add前)
git restore <file>
Lesson 2-5 →
ステージングから外す
git restore --staged <file>
Lesson 2-5 →
直前のコミットを修正
git commit --amend
Lesson 2-5 →
HEAD を巻き戻す(変更は残す)
git reset --soft <id>
Lesson 2-5 →
HEAD を巻き戻す(全部消す)
git reset --hard <id>
危険・ローカル限定 Lesson 2-5 →
公開済みコミットを取り消す
git revert <id>
Lesson 2-5 →
ファイルを過去のバージョンに戻す
git restore --source=<id> <file>
Lesson 2-5 →

📥一時退避(stash)

今の編集を退避
git stash
Lesson 3-1 →
メッセージ付きで退避
git stash push -m "WIP: 説明"
Lesson 3-1 →
退避リストを見る
git stash list
Lesson 3-1 →
取り出して削除
git stash pop
Lesson 3-1 →
取り出して残す
git stash apply
Lesson 3-1 →
退避を捨てる
git stash drop
Lesson 3-1 →

🏷️タグ

タグ一覧
git tag
Lesson 3-2 →
軽量タグを作成
git tag v1.0
Lesson 3-2 →
注釈付きタグを作成
git tag -a v1.0 -m "first release"
Lesson 3-2 →
タグを1つpush
git push origin v1.0
Lesson 3-2 →
すべてのタグをpush
git push origin --tags
Lesson 3-2 →
タグを削除(ローカル)
git tag -d v1.0
Lesson 3-2 →
タグを削除(リモート)
git push origin --delete v1.0
Lesson 3-2 →

☁️リモート操作

リモートを登録
git remote add origin <URL>
Lesson 1-6 →
リモート一覧(URL付き)
git remote -v
Lesson 1-6 →
初回push(追跡設定)
git push -u origin main
Lesson 1-6 →
通常のpush
git push
Lesson 1-6 →
取得のみ
git fetch
Lesson 3-4 →
取得+マージ
git pull
Lesson 1-6 →
リモートとローカルの差分
git diff main origin/main
Lesson 3-4 →
リモートブランチを削除
git push origin --delete <branch>
Lesson 3-4 →
リモートのURLを変更
git remote set-url origin <URL>
Lesson 3-4 →

🚫.gitignore と追跡対象

フォルダ全体を無視
node_modules/
.gitignore に書く Lesson 2-4 →
拡張子で無視
*.log
.gitignore に書く Lesson 2-4 →
例外的に追跡
!important.log
.gitignore に書く Lesson 2-4 →
既に追跡中のものを追跡解除
git rm --cached <file>
ファイルは残る Lesson 2-4 →
ファイル名を変更
git mv <old> <new>
Lesson 2-5 →

💡 このチートシートは レッスン を補完するためのもの。コマンドの意図や注意点はレッスンに詳しく書いてあります。「詳しく →」リンクから当該レッスンに飛べます。

© 2026 git-ready-easy — プログラミング未経験でもわかる git 入門