Repository
git init | Initialize new repository |
git clone | Clone remote repository |
git remote add origin | Add remote origin |
git remote -v | List remotes |
Staging & Commits
git add . | Stage all changes |
git add -p | Interactive patch staging |
git commit -m 'msg' | Commit staged changes |
git commit --amend | Amend last commit |
git reset HEAD | Unstage a file |
git stash | Stash uncommitted changes |
git stash pop | Apply last stash |
Branches
git branch | List branches |
git checkout -b | Create and switch branch |
git switch | Switch branch (modern) |
git merge | Merge branch into current |
git rebase | Rebase onto branch |
git branch -d | Delete merged branch |
Remote
git fetch | Fetch remote changes |
git pull | Fetch + merge |
git push origin | Push to remote |
git push --force-with-lease | Safe force push |
History
git log --oneline --graph | Visual commit history |
git diff | Show unstaged changes |
git diff --staged | Show staged changes |
git blame | Show who changed each line |
git bisect start | Binary search for bug |