Setup and remotes
git init
git clone <repo-url>
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git remote -v
git remote add origin <repo-url>
git fetch origin
Daily workflow
git status
git add .
git commit -m "message"
git pull --rebase origin main
git push -u origin main
Branches and merges
git branch
git switch -c feature-name
git switch main
git merge feature-name
git branch -d feature-name
git log --graph --oneline --decorate --all
Recover and inspect
git restore file.txt
git restore --staged file.txt
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert <commit>
git reflog
Stash, rebase and release
git stash push -m "wip"
git stash pop
git rebase main
git cherry-pick <commit>
git tag -a v1.0.0 -m "Release v1.0.0"
git push --tags