Git Cheat Sheet
Every Git command in the library, on one page. Search, filter by category, or jump to a full command reference for detailed examples.
| Command | Syntax | Description | |
|---|---|---|---|
| git status | git status [--short] | Shows the state of the working directory and staging area — which files are staged, unstaged, or untracked. | |
| git add | git add <pathspec>... | Stages changes so they'll be included in the next commit. | |
| git commit | git commit -m <message> | Records the currently staged changes as a new commit. | |
| git push | git push <remote> <branch> | Uploads local commits on the current branch to a remote repository. | |
| git pull | git pull [--rebase] <remote> <branch> | Fetches commits from a remote and merges (or rebases) them into the current branch. | |
| git branch | git branch [-d] [<branch-name>] | Lists, creates, or deletes branches. | |
| git checkout | git checkout <branch> | git checkout -b <new-branch> | Switches branches or restores working-tree files. | |
| git merge | git merge <branch> | Combines another branch's history into the current branch, creating a merge commit if the histories have diverged. | |
| git rebase | git rebase <branch> | git rebase -i <branch> | Replays the current branch's commits on top of another branch, producing a linear history instead of a merge commit. | |
| git log | git log [--oneline] [--graph] | Shows commit history for the current branch. | |
| git diff | git diff [--staged] [<commit>..<commit>] | Shows changes between commits, the working tree, and the staging area. | |
| git stash | git stash [pop | list | drop] | Temporarily shelves uncommitted changes so you can switch context, then reapplies them later. |