Git Commands & Shortcuts 44 shortcuts · All platforms · Last updated Nov 2026
Half of Git fluency is knowing the command instantly, the other half is shell shortcuts that fix typos without starting over. This cheat sheet covers the daily Git workflow — setup, branching, remotes, history and undo — plus the readline shortcuts that make the terminal usable.
Setup & Config5
| Action | Command |
|---|---|
| Set your name / email globally | gitthenconfigthen--globalthenuser.name |
| Set your email globally | gitthenconfigthen--globalthenuser.email |
| Initialize a new repository | gittheninit |
| Clone a remote repository | gitthenclone |
| Open help for any command | gitthenhelp |
Basics10
| Action | Command |
|---|---|
| Show working tree status | gitthenstatus |
| Stage a specific file | gitthenadd |
| Stage all changes | gitthenaddthen-A |
| Commit staged changes | gitthencommit |
| Amend the last commit | gitthencommitthen--amend |
| Stash current changes | gitthenstash |
| Apply the latest stash | gitthenstashthenpop |
| Show unstaged changes | gitthendiff |
| Show staged changes | gitthendiffthen--staged |
| Show commit history | gitthenlog |
Branching & Merging6
| Action | Command |
|---|---|
| List all branches | gitthenbranch |
| Switch to a branch | gitthenswitch |
| Create and switch to new branch | gitthenswitchthen-c |
| Merge a branch into the current one | gitthenmerge |
| Delete a merged branch | gitthenbranchthen-d |
| Rebase current branch onto another | gitthenrebase |
Remotes5
| Action | Command |
|---|---|
| Add a remote | gitthenremotethenadd |
| Fetch changes without merging | gitthenfetch |
| Fetch and merge in one step | gitthenpull |
| Push local commits | gitthenpush |
| Push and set upstream branch | gitthenpushthen-u |
History & Inspection5
| Action | Command |
|---|---|
| Compact one-line history | gitthenlogthen--oneline |
| History with branch graph | gitthenlogthen--onelinethen--graph |
| Inspect a specific commit | gitthenshow |
| Show who changed each line | gitthenblame |
| List every action taken (safety net) | gitthenreflog |
Undo5
| Action | Command |
|---|---|
| Discard changes in a file | gitthenrestore |
| Unstage a file | gitthenrestorethen--staged |
| Reset to a previous commit | gitthenreset |
| Undo a commit with a new commit | gitthenrevert |
| Remove untracked files | gitthenclean |
Shell Shortcuts8
| Action | Command |
|---|---|
| Search command history | CtrlR |
| Cancel the current command | CtrlC |
| Clear the screen | CtrlL |
| Exit the shell session | CtrlD |
| Autocomplete file / command names | Tab |
| Jump to start / end of line | CtrlAorCtrlE |
| Delete the word before the cursor | CtrlW |
| Delete everything before the cursor | CtrlU |