The commands you reach for during a normal working day with Git, grouped by what you are trying to do rather than by how the manual is ordered.
The repeated git is left out of every row, so only the part that changes is printed.
Read only. Every row starts with git.
status -sb-
Short status with the branch and its tracking state on top
log --oneline --graph --decorate-
The history as a readable graph
diff-
What you changed but have not staged
diff --staged-
What the next commit will contain
show HEAD-
The full content of one commit
blame path/to/file-
Which commit last touched each line
Local. Every row starts with git.
add -p-
Stage change by change and review each one
add .-
Stage everything below the current directory
restore --staged path-
Take a file back out of the staging area
commit -m 'message'-
Commit what is staged
commit --amend-
Fold the staged changes into the last commit
stash push -m 'wip'-
Park unfinished work and get a clean tree
stash pop-
Bring the parked work back
Local. Every row starts with git.
switch -c feature/name-
Create a branch and move onto it
switch main-
Move to an existing branch
branch -vv-
List branches with their upstream and last commit
merge main-
Bring another branch into this one
rebase main-
Replay your commits on top of another branch
rebase -i main-
Reorder, squash or reword commits before review
branch -d feature/name-
Delete a branch that is already merged
Remote. Every row starts with git.
fetch --all --prune-
Update remote branches and drop the ones that are gone
pull --rebase-
Get new commits without an extra merge commit
push -u origin HEAD-
Push the current branch and set its upstream
push --force-with-lease-
Push a rebased branch, refusing if someone else pushed first
remote -v-
Show where fetch and push actually go
Prefer --force-with-lease over --force, it stops you from overwriting work you never saw.
|
Local. Every row starts with git.
restore path-
Throw away the uncommitted changes in one file
reset --soft HEAD~1-
Undo the last commit, keep the changes staged
reset --hard origin/main-
Make the branch identical to another ref
revert 1a2b3c4-
Add a new commit that undoes an old one
reflog-
Every position HEAD has had, including the ones you lost
reset --hard deletes uncommitted work with no way back, reflog only rescues commits, not an unsaved tree.
|
~/.gitconfig. Every row starts with git.
config --global --edit-
Open your global config in your editor
worktree add ../review origin/main-
Check out a second branch in a second directory
bisect start-
Binary search the history for the commit that broke it
[alias]
lg = log --oneline --graph --decorate
st = status -sb
[pull]
rebase = true
Every command is explained in the Git tutorial. (©) 2026 vogella GmbH, see the license.