Permalink
Browse files

add script that tells you where the git repository root of any file/d…

…irectory is (if any)
  • Loading branch information...
1 parent 42ea369 commit 3b7be5e25052e99d9be8ca7d9e6d5c91f8c2a14a @Dieterbe committed Aug 11, 2010
Showing with 13 additions and 0 deletions.
  1. +13 −0 git-root
View
@@ -0,0 +1,13 @@
+#!/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
+if [ -n "$1" ]
+then
+ if [ -d "$1" ]
+ then
+ cd $1
+ else
+ cd `dirname $1`
+ fi
+fi
+cdup=$(git rev-parse --show-cdup)
+exec readlink -f ./$cdup

0 comments on commit 3b7be5e

Please sign in to comment.