When an external command is run via Git alias, it is run from the rood directory of the repository (where the .git/ is usually located). It can be checked with:
$ cd /some/path/inside/repo
$ echo $(git -c alias.root='!pwd' root)
Now, is there a way to get the exact path where the alias was run from?`
In case of XY problem, here's what I'm doing: I want an alias that launches shell function which, in its turn, runs several Git commands, like ls-files. It should work only in the path where it was called, so it should know it.
It works well if I just run the function, because it doesn't change paths and runs exactly where it was called. But I want a little more native behaviour. What I have now is
git-add-specificname -opt -opt2 --long-option -- path1 path2
What I want is
git add-specificname -opt -opt2 --long-option -- path1 path2
Aliasing parameters in Git is not allowed, so no chance for git add specificname...