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.system('hg -q stat 2> /dev/null > /dev/null') == 0)
system('git rev-parse') will return true if the current directory is in a git repo, and false otherwise. I imagine the pythonic equivalent should work similarly.
EDIT: Sure enough:
# in a git repo, running ipython >>> system('git rev-parse') 0 # not in a git repo >>> system('git rev-parse') 32768
Note that there is some output on STDERR when you aren't in a repo, if that matters to you.