🔀 Gitチートシート
| コマンド | 用途 | 例 |
|---|---|---|
git init | リポジトリを新規作成 | git init |
git clone | リモートリポジトリをコピー | git clone https://github.com/user/repo.git |
git status | 変更状態を確認 | git status |
git add | 変更をステージに追加 | git add . / git add ファイル名 |
git commit | 変更を記録 | git commit -m "メッセージ" |
git log | コミット履歴を表示 | git log --oneline |
git diff | 変更内容を表示 | git diff / git diff --staged |
git branch | ブランチ一覧・作成 | git branch feature/login |
git checkout | ブランチ切替 | git checkout -b feature/login |
git switch | ブランチ切替(新構文) | git switch -c feature/login |
git merge | ブランチを統合 | git merge feature/login |
git rebase | コミット履歴を整理して統合 | git rebase main |
git remote | リモート接続の管理 | git remote add origin URL |
git push | リモートに送信 | git push origin main |
git pull | リモートから取得+マージ | git pull origin main |
git fetch | リモートから取得(マージなし) | git fetch origin |
git stash | 変更を一時退避 | git stash / git stash pop |
git reset | コミットを取り消し | git reset --soft HEAD~1 |
git revert | コミットを打ち消す新コミット | git revert コミットID |
git cherry-pick | 特定のコミットだけ取り込む | git cherry-pick コミットID |
git tag | バージョンタグを付ける | git tag v1.0.0 |
.gitignore | 追跡しないファイルを指定 | node_modules/ |
git config | 設定の確認・変更 | git config --global user.name "名前" |
git rm --cached | 追跡を解除(ファイルは残す) | git rm --cached ファイル名 |
git blame | 各行の最終変更者を表示 | git blame ファイル名 |
📖 関連する用語
❓ よくある質問
Gitチートシートはどんな人向け?
Git初心者〜中級者向け。基本コマンドからブランチ操作まで網羅しています。
印刷して使える?
はい。印刷に最適化されたレイアウトで出力されます。
GitとGitHubの違いは?
Gitはバージョン管理ツール、GitHubはGitリポジトリのホスティングサービスです。
⚠️ よくあるエラー
- refusing to merge unrelated histories — 履歴が無関係
- failed to push some refs — リモートが先に進んでいる
- Permission denied (publickey) — SSH鍵の問題