Git Commands I Always Forget
A running list of git commands I find useful but can never quite remember.
Undo the last commit (keep changes)
git reset --soft HEAD~1Interactive rebase for the last N commits
git rebase -i HEAD~3See what changed between two branches
git diff main..feature-branch --statDelete all merged local branches
git branch --merged main | grep -v "main" | xargs git branch -dStash with a message
git stash push -m "WIP: working on auth flow"Find which commit introduced a bug
git bisect start
git bisect bad # current commit is broken
git bisect good abc123 # this commit was fine
# git will checkout commits for you to test
git bisect reset # when doneAmend the last commit message
git commit --amend -m "better message"Cherry-pick a commit from another branch
git cherry-pick <commit-hash>