Skip to content

Instantly share code, notes, and snippets.

@etiennebr
Created January 8, 2021 14:08
Show Gist options
  • Save etiennebr/27a26a22675377f2fe4b87f842464bac to your computer and use it in GitHub Desktop.
Save etiennebr/27a26a22675377f2fe4b87f842464bac to your computer and use it in GitHub Desktop.
Useful fit aliases

Useful git aliases

From git book

Unstage

 git config --global alias.unstage 'reset HEAD --'

Last

git config --global alias.last 'log -1 HEAD'

Autostash for checkout (switch)

git config alias.switch '!git stash && git fetch && git checkout $1 && git stash pop && echo'

I use echo here to avoid the 'branch' is not a stash reference error, since it seems alias appends the branch at the end of the command regardless that it is consumed by $1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment