git
45 commands
45 shown
Interactive rebase last N commits
Squash, reorder, or edit the last 5 commits
git rebase -i HEAD~5
Cherry-pick commit
Apply a single commit from another branch
git cherry-pick <sha>
Reflog — rescue lost commits
Show recent HEAD movements including rebases and resets
git reflog show --date=relative | head -20
Stash with message
Save uncommitted work (including untracked files) with a label
git stash push -m 'WIP: feature-x' -u
Apply stash by index
Apply and drop a specific stash entry
git stash pop stash@{2}
Bisect — find broken commit
Binary search through history to find a regression
git bisect start && git bisect bad HEAD && git bisect good <good-sha>
Worktree — multiple branches
Check out a branch in a parallel directory without stashing
git worktree add ../feature-branch feature/my-feature
Submodule update
Initialize and update all submodules recursively
git submodule update --init --recursive
Show file at specific commit
Print the content of a file at a historical commit
git show <sha>:path/to/file
Log with graph
Compact visual branch graph of the entire repo
git log --oneline --graph --decorate --all | head -40
Grep across history
Find all commits that added or removed the string 'password'
git log -S 'password' --oneline --all
Amend last commit message
Include staged changes in last commit without changing message
git commit --amend --no-edit
Delete remote branch
Remove a branch from the remote repository
git push origin --delete feature/old-branch
Clean untracked files
Remove untracked files and directories (incl. gitignored)
git clean -fdx
Fetch all remotes and prune
Update all remotes and delete stale tracking branches
git fetch --all --prune --tags
Amend last commit message
Rewrite the most recent commit message (local only)
git commit --amend -m 'new message'
Interactive rebase last N commits
Squash, reorder, or edit last 5 commits
git rebase -i HEAD~5
Stash with message
Stash only src/ with a descriptive name
git stash push -m 'wip: feature-x' -- src/
Apply specific stash
List stashes and apply a specific one by index
git stash list && git stash apply stash@{2}
Cherry-pick a range of commits
Apply commits from A to B (inclusive) onto current branch
git cherry-pick A^..B
Show who changed a line (blame)
Annotate lines 10–25 with author and date
git blame -L 10,25 --date=short src/main.py
Find commit that introduced a bug
Binary search through history to find the breaking commit
git bisect start && git bisect bad HEAD && git bisect good v1.0
Show changed files between branches
List files added, modified, deleted between two branches
git diff --name-status main..feature/x
Graph log one-liner
ASCII branch graph of the full commit history
git log --oneline --graph --decorate --all
Undo last commit keep changes
Move HEAD back one commit; staged changes return to working tree
git reset HEAD~1
Discard all local changes
Reset tracked files and remove untracked files/directories
git restore . && git clean -fd
Show tags with messages
List all tags with their first annotation line
git tag -l -n1
Create signed tag
GPG-signed annotated tag for releases
git tag -s v1.2.3 -m 'Release 1.2.3'
Prune remote tracking branches
Remove local refs to remote branches that no longer exist
git fetch --prune
Clone with limited depth
Clone only the latest commit of one branch (fast CI checkout)
git clone --depth=1 --single-branch --branch main <url>
List contributors by commit count
Ranked list of authors by total commit count
git shortlog -sn --all
Search commit messages
Find all commits whose message contains a pattern
git log --all --grep='fix:' --oneline
Search commit diffs (pickaxe)
Find when a string was added or removed across all branches
git log -S 'functionName' --patch --all
Partial clone (blobless)
Download commits and trees; blobs fetched on-demand (fast)
git clone --filter=blob:none <url>
Worktree for parallel branches
Check out a branch in a separate directory without switching
git worktree add ../hotfix-branch hotfix/urgent
Interactive rebase last N commits
Interactively reorder, squash, or edit last 5 commits
git rebase -i HEAD~5
Cherry-pick a commit
Apply a specific commit from another branch
git cherry-pick abc1234
Stash with message
Save working changes with a descriptive stash message
git stash push -m "WIP: feature X"
Show stash list
Show all stashed changesets
git stash list
Apply stash by index
Apply a specific stash entry without dropping it
git stash apply stash@{2}
Find which commit introduced a bug
Start binary search for the commit that introduced a bug
git bisect start && git bisect bad && git bisect good v1.0
Show file change history
Show full diff history of a file including renames
git log --follow -p -- path/to/file.py
Undo last commit (keep changes)
Move HEAD back one commit, keeping staged changes
git reset --soft HEAD~1
Clean untracked files
Remove untracked files and directories from working tree
git clean -fd
Show branches merged into main
List local branches already merged into main
git branch --merged main
no commands match