Git Cheat Sheet
git · reference · commands
セットアップ
git config --global user.name "Name"Set your global username
git config --global user.email "email"Set your global email
git config --global core.editor "code --wait"Set VS Code as default editor
git config --listList all configuration settings
初期化
git initInitialize a new local repository
git clone <url>Clone a remote repository
git clone <url> <dir>Clone into a specific directory
ステージング & スナップショット
git statusShow working tree status
git add <file>Stage a specific file
git add .Stage all changes
git add -pInteractively stage hunks
git diffShow unstaged changes
git diff --stagedShow staged changes
git commit -m "message"Commit staged changes
git commit -am "message"Stage tracked files and commit
git commit --amendAmend the last commit
ブランチ & マージ
git branchList local branches
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to new branch
git switch <branch>Switch branches (modern syntax)
git switch -c <branch>Create and switch (modern)
git merge <branch>Merge branch into current
git branch -d <branch>Delete a branch
git branch -D <branch>Force delete a branch
リモート
git remote -vList remotes
git remote add origin <url>Add a remote
git fetchFetch all remotes
git pullFetch and merge from remote
git pull --rebaseFetch and rebase from remote
git push origin <branch>Push branch to remote
git push -u origin <branch>Push and set upstream
git push --force-with-leaseSafe force push
取り消し & リセット
git revert <commit>Create revert commit
git reset HEAD <file>Unstage a file
git reset --soft HEAD~1Undo last commit, keep staged
git reset --hard HEAD~1Undo last commit, discard changes
git checkout -- <file>Discard file changes
git clean -fdRemove untracked files/dirs
スタッシュ
git stashStash working directory changes
git stash listList all stashes
git stash popApply latest stash and remove
git stash apply stash@{n}Apply specific stash
git stash drop stash@{n}Delete a stash
ログ & 確認
git log --onelineCompact commit history
git log --oneline --graph --allVisual branch graph
git log --author="Name"Filter commits by author
git show <commit>Show commit details
git blame <file>Show who changed each line
git diff <branch1>..<branch2>Diff between branches
使い方
- 1
コマンドや説明で検索します。
- 2
セクションごとにgitコマンドを見ます。
- 3
項目をクリックでコマンドをコピーします。
FAQ
このツールは無料ですか?
はい、登録もインストールも不要で、すぐに完全無料で使えます。
このツールはどんなツールですか?
必須Gitコマンドのクイックリファレンス。カテゴリ別整理、検索、クリックでコピーに対応。 登録もインストールも不要で、ページを開けばすぐに無料でお使いいただけます。