Mercurial has a way of printing the root directory (that contains .hg) via
hg root
Is there something equivalent in git to get the director
I wanted to expand upon Daniel Brockman's excellent comment.
Defining git config --global alias.exec '!exec '
allows you to do things like git exec make
because, as man git-config
states:
If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command. [...] Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory.
It's also handy to know that $GIT_PREFIX
will be the path to the current directory relative to the top-level directory of a repository. But, knowing it is only half the battle™. Shell variable expansion makes it rather hard to use. So I suggest using bash -c
like so:
git exec bash -c 'ls -l $GIT_PREFIX'
other commands include:
git exec pwd
git exec make