Is there an equivalent command to this that always returns the absolute path?
git rev-parse --git-path hooks
When I'm in a submodule, I get an absolute path, but when I'm in the root repository, I get
.git/hooks
Git v2.13.0 has --absolute-git-dir
:
$ git rev-parse --absolute-git-dir
/Users/torek/...snip.../.git
but not --absolute-git-path
, and as you note, --git-path
produces a relative result:
$ git rev-parse --git-path hooks
.git/hooks
If you do have Git 2.13, though, you can combine these using the sh/bash environment variable prefix method:
$ GIT_DIR=$(git rev-parse --absolute-git-dir) git rev-parse --git-path hooks
/Users/torek/...[snip].../.git/hooks
If not—if your Git is older than 2.13—you can use readlink -f
:
$ GIT_DIR=$(readlink -f $(git rev-parse --git-dir)) git rev-parse --git-path hooks
/home/vagrant/...snip.../.git/hooks
(in a certain Linux image on my laptop; this particular Linux image has Git 2.7.4 installed).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With