Matt
Matt

Reputation: 1704

How do I configure a parameterized git alias?

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.

Upvotes: 3

Views: 42

Answers (1)

phd
phd

Reputation: 94483

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.

Upvotes: 2

Related Questions