git - 你如何在某些 Git 存储库中获取 Git 存储库的名称?

标签 git repository

当您在某个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/

相关文章:

github - 我可以在不丢失链接目标的情况下将 github 存储库名称从大写更改为小写吗?

git - 为什么 "git rebase"给 "error: patch does not apply"只提交空白?

git - 如何在已删除的分支上重新提交旧提交?

git - Android Studio 2.1.2 启用版本控制集成

java - 编译渲染脚本源代码

git - Git:将两个存储库彼此 merge

Git 错误 : Unable to negotiate with XX. XX.XXX.XXX : no matching host key type found . 他们的报价:ssh-dss

SVN 存储库比转储文件大得多?

SVN远程仓库

linux - 如何将存储库从 SVN 导入/导出到新的 SVN