How can I tell if a given directory is part of a git respository?
(The following is in python, but bash or something would be fine.)
os.path.isdir(\'.svn
For the record, use git status or similar, this is just for completeness: :)
Searching upward a tree is no biggie really, in bash you can do this simple one-liner (if you put it on one line...) ;) Returns 0 if one is found, 1 otherwise.
d=`pwd`
while [ "$d" != "" ]; do
[ -d "$d"/.git ] && exit 0
d=${d%/*}
done
exit 1
will search upward looking for a .git folder.