Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Git Cheat Sheet

Setup and basics

// configure once
git config --global user.name "Name"
git config --global user.email "you@example.com"
git init
git clone <url>
git status
git add <file>
git add .
git commit -m "message"
git log --oneline --graph

Branches

git branch
git switch -c feature/x
git switch main
git merge feature/x
git branch -d feature/x
git rebase main

Remote

git remote add origin <url>
git push -u origin main
git pull
git fetch --all --prune
git push origin --delete old-branch

Undo

git restore <file>
git restore --staged <file>
git commit --amend
git revert <sha>
git reset --soft HEAD~1
git stash
git stash pop
git reflog

Inspect

git diff
git diff --staged
git show <sha>
git blame <file>
git log -p -- <file>
git shortlog -sn

Full Git documentation