当您在某个Git 目录中工作时,如何获取某个Git 存储库中的Git 存储库名称?有没有 Git 命令?
# 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
最佳答案
好吧,如果对于存储库名称,您指的是 Git 根目录名称(包含 .git
目录的目录),您可以运行此命令:
basename `git rev-parse --show-toplevel`
git rev-parse --show-toplevel
部分为您提供该目录的路径,basename
去除路径的第一部分。
关于git - 你如何在某些 Git 存储库中获取 Git 存储库的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15715825/