Last active
December 21, 2015 09:09
-
-
Save jdsumsion/6282953 to your computer and use it in GitHub Desktop.
git-root script that prints the root of a git repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment