Cheatsheet
Git Commands Cheatsheet
The most useful git commands you actually need, organized by task. Copy any command with one click.
Setup & Init
git initInitialize a new repo git clone <url>Clone a remote repo git config --global user.name "Name"Set your name git config --global user.email "email"Set your email Day-to-Day
git statusSee changed files git add .Stage all changes git add <file>Stage a specific file git commit -m "message"Commit staged changes git pushPush to remote git pullPull latest from remote git log --oneline -10Last 10 commits (compact) git diffSee unstaged changes Branching
git branchList branches git checkout -b <branch>Create and switch to branch git switch <branch>Switch branch (modern) git merge <branch>Merge branch into current git branch -d <branch>Delete a merged branch git rebase <branch>Rebase current onto branch Undo & Fix
git stashStash uncommitted changes git stash popRestore stashed changes git reset HEAD~1Undo last commit (keep changes) git checkout -- <file>Discard changes to a file git commit --amendEdit the last commit message