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.

CommandSyntaxDescription
git statusgit status [--short]Shows the state of the working directory and staging area — which files are staged, unstaged, or untracked.
git addgit add <pathspec>...Stages changes so they'll be included in the next commit.
git commitgit commit -m <message>Records the currently staged changes as a new commit.
git pushgit push <remote> <branch>Uploads local commits on the current branch to a remote repository.
git pullgit pull [--rebase] <remote> <branch>Fetches commits from a remote and merges (or rebases) them into the current branch.
git branchgit branch [-d] [<branch-name>]Lists, creates, or deletes branches.
git checkoutgit checkout <branch> | git checkout -b <new-branch>Switches branches or restores working-tree files.
git mergegit merge <branch>Combines another branch's history into the current branch, creating a merge commit if the histories have diverged.
git rebasegit 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 loggit log [--oneline] [--graph]Shows commit history for the current branch.
git diffgit diff [--staged] [<commit>..<commit>]Shows changes between commits, the working tree, and the staging area.
git stashgit stash [pop | list | drop]Temporarily shelves uncommitted changes so you can switch context, then reapplies them later.