📦

Git Cheat Sheet

Branch, merge, stash, revert, and remote workflow.

Related: git · github-cli

Daily workflow

CommandDescription
git statusChanged files and branch
git pull --rebase origin mainUpdate branch with rebase
git add -pStage hunks interactively
git commit -m "feat: message"Commit staged changes
git push -u origin feature-branchPush and set upstream

Branch & merge

CommandDescription
git branch -aLocal and remote branches
git checkout -b feature/xCreate and switch branch
git merge mainMerge main into current branch
git rebase mainRebase onto main
git branch -d feature/xDelete merged branch

Undo & stash

CommandDescription
git stash push -m "wip"Save WIP changes
git stash popRestore latest stash
git revert <commit>Safe undo — new commit
git reset --hard origin/mainDiscard local commits (destructive)
git log --oneline -10Recent commits