Git Aliases vs Bash Aliases

This is a really pedantic topic I recognize.

In the “Mastering Git” video git aliases are added to .gitconfig and handled through git. Previously, I did these as bash aliases and so just to try a change I moved them from bash/aliases over to gitconfig. Previously I had ‘gcm’ for ‘git commit --mesage’, now I have ‘g cm’ (I adopted the g git alias because it’s awesome).

As far as I can tell the advantage of putting git specific alias in .gitconfig are:

  1. All git aliases are located with git.
  2. All the aliases previously in bash are now freed up for other things.
  3. running, ‘git alias’ let’s you only see git specific aliases rather than having to sift through all of them.

Are there any other advantages that I might not be noticing?

You can execute shell commands in a Git alias, but if your alias is doing more shell magic than Git magic, it’s probably better as a shell alias.

If you’re using a Git shell like gitsh, your Git aliases are available there, which is an added bonus of a Git alias. Git aliases are also available in all shells regardless of their configuration sourcing.

1 Like