# Cheat sheet

A quick reference for the most common Git commands. For detailed explanations, see the other chapters in this guide.

# Everyday commands

Action Command
Check current branch & status git status
See what changed (unstaged) git diff
See what changed (staged) git diff --staged
Stage all changes git add .
Commit with a message git commit -m "your message"
Push changes git push
Pull latest changes git pull

# Branching

Action Command
Create & switch to new branch git switch -c branch-name
Switch to existing branch git switch branch-name
Create & switch (older alternative) git checkout -b branch-name
Switch (older alternative) git checkout branch-name
Push new branch (first time) git push -u origin branch-name
List all local branches git branch
List all branches (incl. remote) git branch -a
Delete local branch (merged) git branch -d branch-name
Delete remote branch git push origin --delete branch-name

# Keeping branches in sync

Action Command
Update main git switch maingit pull
Merge main into feature branch git switch feature-branchgit merge main

# Stashing

Action Command
Save uncommitted changes git stash
Restore saved changes git stash pop
List all stashes git stash list
Discard a stash git stash drop

# Undoing changes

Action Command
Discard changes in a file git restore filename
Unstage a file git restore --staged filename

# Viewing history

Action Command
Compact commit log git log --oneline
Last N commits git log --oneline -N
Visual branch graph git log --oneline --graph --all

# References

Last Updated: 2/11/2026, 11:52:40 AM