September 11, 2026 · Yunus Emre Vurgun
Git Commands Cheat Sheet
Fifteen git commands cover the daily workflow of most developers: set up, stage, commit, branch, sync, inspect, and undo. This cheat sheet lists each one with exactly what it does — no flags you will never type.
Setup and sync
| Command | What it does |
|---|---|
git init | Initialize a new Git repository in the current directory. |
git clone <url> | Clone a remote repository to your local machine. |
git push | Upload local commits to the remote repository. |
git pull | Fetch and merge changes from the remote branch. |
Stage, commit, branch
| Command | What it does |
|---|---|
git add <file> | Stage changes for the next commit. Use git add . for all. |
git commit -m "msg" | Commit staged changes with a descriptive message. |
git branch -a | List all local and remote branches. |
git checkout <branch> | Switch to the specified branch. Use -b to create and switch. |
git merge <branch> | Merge the specified branch into the current branch. |
git rebase <branch> | Reapply commits on top of another branch. Use with caution on public branches. |
git cherry-pick <hash> | Apply a specific commit by hash onto the current branch. |
Inspect and undo
| Command | What it does |
|---|---|
git stash | Temporarily store uncommitted changes. Use git stash pop to restore. |
git log --oneline -10 | Show the last 10 commits in compact format. |
git diff | Show unstaged changes. Use git diff --staged for staged changes. |
git reset --soft HEAD~1 | Undo the last commit, keeping changes staged. |
The one rule for shared branches
Never rebase commits that someone else has pulled. Rebase rewrites history, so collaborators end up with duplicate commits and a merge mess. On a shared branch, merge; on your own short-lived branch, rebase freely. For the workflow around these commands, see Version Control Workflows.
Fetch it as data
This sheet is the Git Essential Commands dataset — handy when an agent needs to suggest or validate git invocations:
curl "https://yjtoon.com/api/dataset/git-essential-commands?format=toon"Pair it with the Unix file commands cheat sheet for the terminal half of the workflow.