Git Aliases can be set as following:
git config --global alias.unstage 'reset HEAD --'
This makes the following two commands equivalent:
$ git unstage fileA
$ git reset HEAD -- fileA
To use a non-git command, prefix it with a !
:
git config --global alias.visual '!gitk'
To list all aliases, we can use
git config --get-regexp ^alias
Some aliases that I use
alias | command |
---|---|
unstage <file> | reset HEAD -- <file> |
amend | git stage -A && git commit --amend --no-edit |
force-push | git push --force-with-lease |