Is there a reliable way to check for a potential Git alias?

Git allows you to create your own custom Git verbs or aliases using

git config [--global] alias.<alias-name> "<replacement-text>"

      

If you are not very familiar with Git commands, you can choose an alias to match an existing Git verb; as an extremely dumb example, consider

git config --global alias.log show

      

No panic; according to git config --help

:

To avoid confusion and problems with script usage, aliases that hide existing Git commands are ignored.

Okay, but in this case, Git won't tell you that your new alias will be ignored .

So I'm wondering if there is a reliable (and future) way to check if my alias name matches an existing Git verb before defining the alias.

I thought about searching <alias-name>

the output git help --all

, but the latter contains more than just a list of all Git verbs, so I'm not sure how reliable that approach would be ...

Any idea?

+3


source to share


1 answer


Of course, just run git help <command name>

.



  • If a command exists, this will bring up the man page for the corresponding command.
  • If the command is an existing alias, you will get something line by line 'git l' is aliased to 'log'

  • If the command does not exist, you will receive an error message
+2


source







All Articles