Search tools

Search for a command to run...

Git Commands Cheat Sheet

The Git commands you actually need — setup, branching, undoing mistakes, stashing, rebasing and working with remotes — with what each does.

How to use

  1. 1Search for a task, like 'undo' or 'branch'.
  2. 2Copy the command and replace the placeholders in <angle brackets>.

Frequently asked questions

How do I undo my last commit but keep the changes?

git reset --soft HEAD~1 moves the branch back one commit and leaves the changes staged.

What's the difference between merge and rebase?

Merge joins histories with a merge commit. Rebase replays your commits on top of another branch for a linear history — don't rebase commits others already pulled.

How do I get back something I deleted?

git reflog lists every position HEAD has been in. Find the commit and git checkout or git reset to it.