Loading...
Loading...
From clone to interactive rebase, the git commands you reach for daily, grouped by intent with the dangerous ones flagged.
Get oriented in any repo.
git initStart a new repo.git clone <url>Copy a remote repo locally.git statusWhat's changed, staged, untracked.git log --oneline --graph --allVisual commit history.git remote -vShow configured remotes.Capture changes into the history.
git add <file>Stage specific files (preferred).git add -pStage hunks interactively.git commit -m "msg"Commit staged changes.git commit --amendEdit the last commit (only if not pushed).git restore --staged <file>Unstage without losing changes.Workflow building blocks.
git switch -c <name>Create + switch to a branch (modern).git switch <name>Switch to an existing branch.git merge <branch>Merge another branch into current.git branch -d <name>Delete a merged branch.git branch -D <name>Force-delete an unmerged branch.Rewrite history carefully.
git rebase mainReplay your branch on top of main.git rebase -i HEAD~5Interactive: squash, fix, reword recent commits.git cherry-pick <sha>Apply a specific commit elsewhere.git reflogTime-travel every HEAD change is here.Move work-in-progress around.
git stashStash uncommitted changes.git stash popRe-apply most recent stash.git restore <file>Discard local changes to a file.Push, pull, and reset relationships.
git fetchGet refs without merging.git pull --rebasePull and replay your work on top.git push -u origin <branch>Push and track upstream.git push --force-with-leaseSafer force push (fails if remote moved).git push --forceOverwrite remote history.When something is wrong, take a breath and try these.
git reset HEAD~1Undo last commit; keep changes staged.git reset --hard <sha>Hard reset to a commit.git revert <sha>Undo a commit by adding a new commit.git clean -fdDelete untracked files & dirs.Rule of thumb: commands flagged with the warning icon rewrite or destroy history. Use --force-with-lease over --force, and never reset published commits.
We turn AI cheatsheets into production code. Tell us what you're building.