Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 15 lines (14 sloc) 408 Bytes
#!/bin/sh -e
# inspired by http://stackoverflow.com/questions/957928/is-there-a-way-to-get-to-the-git-root-directory-in-one-command/3009378#3009378
# gives absolute path to git repository root, either for cwd, or directory (or files' dirname) given as $1
# when not a git repository, exit >0
if [ -n "$1" ]
then
if [ -d "$1" ]
then
cd $1
else
cd `dirname $1`
fi
fi
exec git rev-parse --show-toplevel