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
Here is a script that I've written that handles both cases: 1) repository with a workspace, 2) bare repository.
https://gist.github.com/jdsumsion/6282953
git-root
(executable file in your path):
#!/bin/bash
GIT_DIR=`git rev-parse --git-dir` &&
(
if [ `basename $GIT_DIR` = ".git" ]; then
# handle normal git repos (with a .git dir)
cd $GIT_DIR/..
else
# handle bare git repos (the repo IS a xxx.git dir)
cd $GIT_DIR
fi
pwd
)
Hopefully this is helpful.