September 11, 2026 · Yunus Emre Vurgun

Git Commands Cheat Sheet

git · devops · reference · cli · 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

CommandWhat it does
git initInitialize a new Git repository in the current directory.
git clone <url>Clone a remote repository to your local machine.
git pushUpload local commits to the remote repository.
git pullFetch and merge changes from the remote branch.

Stage, commit, branch

CommandWhat 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 -aList 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

CommandWhat it does
git stashTemporarily store uncommitted changes. Use git stash pop to restore.
git log --oneline -10Show the last 10 commits in compact format.
git diffShow unstaged changes. Use git diff --staged for staged changes.
git reset --soft HEAD~1Undo 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.