git commands
45 commands, each with a one-line explanation. Click a command to copy it, or its title for details.
Commands 45 shown
-
git rebase -i HEAD~5Squash, reorder, or edit the last 5 commits
-
git cherry-pick <sha>Apply a single commit from another branch
-
git reflog show --date=relative | head -20Show recent HEAD movements including rebases and resets
-
git stash push -m 'WIP: feature-x' -uSave uncommitted work (including untracked files) with a label
-
git stash pop stash@{2}Apply and drop a specific stash entry
-
git bisect start && git bisect bad HEAD && git bisect good <good-sha>Binary search through history to find a regression
-
git worktree add ../feature-branch feature/my-featureCheck out a branch in a parallel directory without stashing
-
git submodule update --init --recursiveInitialize and update all submodules recursively
-
git show <sha>:path/to/filePrint the content of a file at a historical commit
-
git log --oneline --graph --decorate --all | head -40Compact visual branch graph of the entire repo
-
git log -S 'password' --oneline --allFind all commits that added or removed the string 'password'
-
git commit --amend --no-editInclude staged changes in last commit without changing message
-
git push origin --delete feature/old-branchRemove a branch from the remote repository
-
git clean -fdxRemove untracked files and directories (incl. gitignored)
-
git fetch --all --prune --tagsUpdate all remotes and delete stale tracking branches
-
git commit --amend -m 'new message'Rewrite the most recent commit message (local only)
-
git rebase -i HEAD~5Squash, reorder, or edit last 5 commits
-
git stash push -m 'wip: feature-x' -- src/Stash only src/ with a descriptive name
-
git stash list && git stash apply stash@{2}List stashes and apply a specific one by index
-
git cherry-pick A^..BApply commits from A to B (inclusive) onto current branch
-
git blame -L 10,25 --date=short src/main.pyAnnotate lines 10–25 with author and date
-
git bisect start && git bisect bad HEAD && git bisect good v1.0Binary search through history to find the breaking commit
-
git diff --name-status main..feature/xList files added, modified, deleted between two branches
-
git log --oneline --graph --decorate --allASCII branch graph of the full commit history
-
git reset HEAD~1Move HEAD back one commit; staged changes return to working tree
-
git restore . && git clean -fdReset tracked files and remove untracked files/directories
-
git tag -l -n1List all tags with their first annotation line
-
git tag -s v1.2.3 -m 'Release 1.2.3'GPG-signed annotated tag for releases
-
git fetch --pruneRemove local refs to remote branches that no longer exist
-
git clone --depth=1 --single-branch --branch main <url>Clone only the latest commit of one branch (fast CI checkout)
-
git shortlog -sn --allRanked list of authors by total commit count
-
git log --all --grep='fix:' --onelineFind all commits whose message contains a pattern
-
git log -S 'functionName' --patch --allFind when a string was added or removed across all branches
-
git clone --filter=blob:none <url>Download commits and trees; blobs fetched on-demand (fast)
-
git worktree add ../hotfix-branch hotfix/urgentCheck out a branch in a separate directory without switching
-
git rebase -i HEAD~5Interactively reorder, squash, or edit last 5 commits
-
git cherry-pick abc1234Apply a specific commit from another branch
-
git stash push -m "WIP: feature X"Save working changes with a descriptive stash message
-
git stash listShow all stashed changesets
-
git stash apply stash@{2}Apply a specific stash entry without dropping it
-
git bisect start && git bisect bad && git bisect good v1.0Start binary search for the commit that introduced a bug
-
git log --follow -p -- path/to/file.pyShow full diff history of a file including renames
-
git reset --soft HEAD~1Move HEAD back one commit, keeping staged changes
-
git clean -fdRemove untracked files and directories from working tree
-
git branch --merged mainList local branches already merged into main
no commands match — try a different search