Git コマンドチートシート

よく使う Git コマンドの分類別早見表。基本操作、ブランチ管理、リモート、取り消しなどを網羅。 完全無料・ブラウザ内ローカル処理・アップロード不要。

Basic

git init— Initialize a new repositoryクリックでコピー
git clone <url>— Clone a remote repositoryクリックでコピー
git status— Show working tree statusクリックでコピー
git add <file>— Stage file(s) for commitクリックでコピー
git add .— Stage all changesクリックでコピー
git commit -m "msg"— Commit staged changesクリックでコピー
git diff— Show unstaged changesクリックでコピー
git diff --staged— Show staged changesクリックでコピー

Branch

git branch— List local branchesクリックでコピー
git branch <name>— Create a new branchクリックでコピー
git checkout <branch>— Switch to branchクリックでコピー
git checkout -b <name>— Create & switch to branchクリックでコピー
git switch <branch>— Switch to branch (new)クリックでコピー
git switch -c <name>— Create & switch (new)クリックでコピー
git merge <branch>— Merge branch into currentクリックでコピー
git branch -d <name>— Delete a branchクリックでコピー
git branch -m <old> <new>— Rename a branchクリックでコピー

Remote

git remote -v— List remote repositoriesクリックでコピー
git remote add <name> <url>— Add a remoteクリックでコピー
git fetch— Fetch from remoteクリックでコピー
git pull— Fetch & mergeクリックでコピー
git push— Push to remoteクリックでコピー
git push -u origin <branch>— Push & set upstreamクリックでコピー
git remote remove <name>— Remove a remoteクリックでコピー

Undo/Reset

git reset HEAD <file>— Unstage a fileクリックでコピー
git checkout -- <file>— Discard working changesクリックでコピー
git restore <file>— Discard working changes (new)クリックでコピー
git reset --soft HEAD~1— Undo last commit, keep stagedクリックでコピー
git reset --mixed HEAD~1— Undo last commit, keep unstagedクリックでコピー
git reset --hard HEAD~1— Undo last commit, discard allクリックでコピー
git revert <commit>— Create undo commitクリックでコピー

Stash

git stash— Stash current changesクリックでコピー
git stash list— List stashesクリックでコピー
git stash pop— Apply & remove latest stashクリックでコピー
git stash apply— Apply latest stashクリックでコピー
git stash drop— Remove latest stashクリックでコピー
git stash push -m "msg"— Stash with a messageクリックでコピー

Log

git log— Show commit historyクリックでコピー
git log --oneline— Compact commit historyクリックでコピー
git log --graph— Graph of branchesクリックでコピー
git log -n <count>— Show last N commitsクリックでコピー
git show <commit>— Show commit detailsクリックでコピー
git blame <file>— Line-by-line historyクリックでコピー

Tag

git tag— List tagsクリックでコピー
git tag <name>— Create lightweight tagクリックでコピー
git tag -a <name> -m "msg"— Create annotated tagクリックでコピー
git tag -d <name>— Delete a tagクリックでコピー
git push origin --tags— Push tags to remoteクリックでコピー