When you are working in some Git directory, how can you get the Git repository name in some Git repository? Are there any Git commands?
# I did check out bar repository and working in somewhere
# under bar directory at this moment such as below.
$ git clone git://github.com/foo/bar.git
$ cd bar/baz/qux/quux/corge/grault # and I am working in here!
$ git xxx # <- ???
bar
Well, if, for the repository name you mean the Git root directory name (the one that contains the .git directory) you can run this:
basename `git rev-parse --show-toplevel`
The git rev-parse --show-toplevel
part gives you the path to that directory and basename
strips the first part of the path.