git

45 commands

45 shown

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