Git alias with positional parameters


Basically I'm trying to alias:

git files 9fa3 execute the command:

git diff --name-status 9fa3^ 9fa3

but git doesn't appear to pass positional parameters to the alias command. I have tried:

    files = "!git diff --name-status $1^ $1"
    files = "!git diff --name-status {1}^ {1}"

...and a few others but those didn't work.

The degenerate case would be:

$ git echo_reverse_these_params a b c d e
e d c b a can I make this work?


A shell function could help on this:

    files = "!f() { git diff --name-status \"$1^\" \"$1\"; }; f"

An alias without ! is treated as a Git command; e.g. commit-all = commit -a.

With the !, it's run as its own command in the shell, letting you use stronger magic like this.

Because commands are executed at the root of repository you may use ${GIT_PREFIX} variable when referring to the file names in commands

What does 'git blame' do?

How do I show my global Git configuration?