Git コマンドチートシート

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

Basic

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

Branch

git branchList 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 -vList remote repositoriesクリックでコピー
git remote add <name> <url>Add a remoteクリックでコピー
git fetchFetch from remoteクリックでコピー
git pullFetch & mergeクリックでコピー
git pushPush 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~1Undo last commit, keep stagedクリックでコピー
git reset --mixed HEAD~1Undo last commit, keep unstagedクリックでコピー
git reset --hard HEAD~1Undo last commit, discard allクリックでコピー
git revert <commit>Create undo commitクリックでコピー

Stash

git stashStash current changesクリックでコピー
git stash listList stashesクリックでコピー
git stash popApply & remove latest stashクリックでコピー
git stash applyApply latest stashクリックでコピー
git stash dropRemove latest stashクリックでコピー
git stash push -m "msg"Stash with a messageクリックでコピー

Log

git logShow commit historyクリックでコピー
git log --onelineCompact commit historyクリックでコピー
git log --graphGraph 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 tagList 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 --tagsPush tags to remoteクリックでコピー