Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure a parameterized git alias?

Tags:

git

I frequently run

git log -10 --author="<author name>" --grep="<story of interest>"

Is it possible to configure a git alias similar to

git by "<author name>" "<story of interest>" -10

that will accomplish the same thing?

The documentation makes no mention of parameters.

like image 249
Matt Avatar asked Feb 15 '26 05:02

Matt


1 Answers

You can create alias as a shell command:

git config alias.agrep '!f() { git log -10 --author="$1" --grep="$2"; }; f'

Now call git agrep with 2 parameters: git agrep Matt test.

See GitAlias repo for dozens of useful aliases and examples. Full disclosure: I'm a contributor.

like image 59
phd Avatar answered Feb 17 '26 21:02

phd