← Cheatsheets
CI/CD

git

Essential git commands for daily version control. Branching, syncing, undoing mistakes and managing history.

Setup & Config

git config --global user.name "Name"
git config --global user.email "email"
git config --list
git init
git clone <url>
git clone <url> --depth=1

Basic Workflow

git status
git add <file>
git add .
git add -p
git commit -m "message"
git commit --amend
git diff
git diff --staged

Branching

git branch
git branch -a
git switch <name>
git switch -c <name>
git merge <branch>
git rebase <branch>
git branch -d <name>
git branch -D <name>

Remote & Sync

git remote -v
git remote add origin <url>
git fetch
git pull
git pull --rebase
git push origin <branch>
git push -u origin <branch>
git push --force-with-lease

History

git log --oneline
git log --oneline --graph --all
git log -p
git log --author="name"
git show <hash>
git blame <file>

Undo & Reset

git restore <file>
git restore --staged <file>
git revert <hash>
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
git clean -fd

Stash

git stash
git stash push -m "message"
git stash list
git stash pop
git stash apply stash@{n}
git stash drop stash@{n}
git stash clear