Cheatsheets

Git cheatsheet

Everyday clone, branch, commit, rebase, and undo commands.

Start and status

Command / topicWhat it does
git clone <url>Copy a remote repository
git statusSee staged, unstaged, and untracked files
git log --oneline -n 10Short recent history
git diffUnstaged changes
git diff --stagedStaged changes

Branch and commit

Command / topicWhat it does
git switch -c feature/xCreate and switch to a branch
git add -pStage hunks interactively
git commit -m "msg"Commit staged changes
git push -u origin HEADPublish the current branch
git pull --rebaseUpdate with rebase instead of merge

Undo safely

Command / topicWhat it does
git restore <file>Discard unstaged file changes
git restore --staged <file>Unstage without losing edits
git reset --soft HEAD~1Undo last commit, keep changes staged
git revert <sha>Add a commit that undoes a past commit

← All cheatsheets · Courses