Mercurial有一种打印根目录(包含.hg)的方法,通过
hg rootgit中有没有等价物可以获取包含.git目录的目录?
发布于 2009-06-05 20:29:13
是:
git rev-parse --show-toplevel如果要更直接地复制Mercurial命令,可以创建一个alias
git config --global alias.root 'rev-parse --show-toplevel'现在,git root的功能就像hg root一样。
注意:在子模块中,这将显示子模块的根目录和,而不是父存储库。如果你使用的是Git >=2.13或更高版本,有一种方法可以让你的git比这更老的话submodules can show the superproject's root directory.,see this other answer.
发布于 2009-12-12 02:33:06
git-config (别名下)的man页面上写道:
如果别名扩展名以感叹号为前缀,则它将被视为外壳命令。..。请注意,shell命令将从存储库的顶级目录执行,该目录不一定是当前目录。
因此,在UNIX上,您可以执行以下操作:
git config --global --add alias.root '!pwd'发布于 2010-09-11 02:14:50
--show-toplevel是最近才添加到git rev-parse中的吗?为什么没有人提到它?
从git rev-parse手册页:
--show-toplevel
Show the absolute path of the top-level directory.https://stackoverflow.com/questions/957928
复制相似问题