Git Cheat Sheet


git config --<system|global|local> <key> <value>:

  • system – system level, config stored in $(git executable folder)/etc/config
  • global – user level, config stored in $(user home folder)/.gitconfig
  • local – repository level, stored in $(repository folder)/.git/config

git config --<level> <name>: git username

git config --<level> <email>: user email

git config --<level> core.editor <editor name>: git editor to use

  • NOTE: without this parameter set, git will default to default system editor set with VISUAL or EDITOR shell parameter


git tag: list tags without descriptions

git tag -n: list tags with annotated descriptions, or description of last commit

git tag -a <name> -m <message>: create annotated tag, with message

git tag <name>: create lightweight tag

git push <remote> --tags: push all local tags to remote

git push <remote> <tag name>: push individual tag

git tag -d <name>: delete tag


git stash: stash most recent changes (but nothing untracked)

git stash save "<description>": stash with description

git stash list: list stashes

git stash pop: apply most recent changes

git stash pop stash@{<id>}: apply stash with ID given in stash list

git stash show: show file changes in stash

git stash show -p: show full stash diff

git stash -p: interactive stash (go through each change and ask if you want to stash it)

git stash branch <branch name> <stash ID>: create new branch from stash

git stash drop <stash ID>: remove stash with stash ID

git stash clear: remove all stashes

Leave a Reply