Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I search my git aliases?

Tags:

git

There are some aliases that I use less frequently and want to check before I execute.

How can I easily search my git aliases?

like image 208
Tom Hale Avatar asked Sep 07 '25 15:09

Tom Hale


2 Answers

Add to your .gitconfig under [alias]:

aliases = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color \"$1\" "#"

Then you can do

  • git aliases commit - show aliases containing "commit"
  • git aliases ^st= - show what the st alias does
  • git aliases - show ALL aliases

The first argument is an (optional) POSIX extended regular expression. Any additional arguments are ignored.

like image 134
Tom Hale Avatar answered Sep 10 '25 04:09

Tom Hale


git --list-cmds=alias lists all aliases.[1] So you can for example pipe that to grep:

git --list-cmds=alias | grep log

Notes

  1. man git as of git version 2.40.0: “This is an internal/experimental option and may change or be removed in the future.”
like image 32
Guildenstern Avatar answered Sep 10 '25 04:09

Guildenstern