DevTools.run

Git Cheatsheet

Essential Git commands

Setup

git init
git clone <url>
git config --global user.name "Name"
git config --global user.email "email"

Basic Workflow

git status
git add <file>
git add .
git commit -m "message"
git push
git pull
git fetch

Branching

git branch
git branch <name>
git checkout <branch>
git checkout -b <name>
git merge <branch>
git branch -d <name>
git branch -m <old> <new>

History & Diff

git log
git log --oneline
git log --graph
git diff
git diff --staged
git show <commit>
git blame <file>

Undoing Changes

git restore <file>
git restore --staged <file>
git reset HEAD~1
git reset --hard HEAD~1
git revert <commit>
git stash
git stash pop

Remote

git remote -v
git remote add origin <url>
git push -u origin <branch>
git push origin --delete <branch>
git pull --rebase

Advanced

git rebase <branch>
git cherry-pick <commit>
git tag <name>
git reflog
git clean -fd
git bisect start