List Git aliases
$ git config --get-regexp alias
This answer builds upon the answer by johnny. It applies if you're not using git-alias
from git-extras
.
On Linux, run once:
git config --global alias.alias "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"
This will create a permanent git alias named alias
which gets stored in your ~/.gitconfig
file. Using it will list all of your git aliases, in nearly the same format as they are in the ~/.gitconfig
file. To use it, type:
$ git alias
loga = log --graph --decorate --name-status --all
alias = ! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /
The following considerations apply:
To prevent the alias
alias
from getting listed as above, append| grep -v ^'alias '
just before the closing double-quote. I don't recommend this so users don't forget that the the commandalias
is but an alias and is not a feature of git.To sort the listed aliases, append
| sort
just before the closing double-quote. Alternatively, you can keep the aliases in~/.gitconfig
sorted.To add the alias as a system-wide alias, replace
--global
(for current user) with--system
(for all users). This typically goes in the/etc/gitconfig
file.