Mercurial有一种打印根目录(包含.hg)的方法,通过
hg rootgit中有没有等价物可以获取包含.git目录的目录?
发布于 2013-08-20 23:32:12
这是我写的一个脚本,可以处理这两种情况: 1)带有工作区的存储库,2)裸存储库。
https://gist.github.com/jdsumsion/6282953
git-root (路径中的可执行文件):
#!/bin/bash
GIT_DIR=`git rev-parse --git-dir` &&
(
if [ `basename $GIT_DIR` = ".git" ]; then
# handle normal git repos (with a .git dir)
cd $GIT_DIR/..
else
# handle bare git repos (the repo IS a xxx.git dir)
cd $GIT_DIR
fi
pwd
)希望这能对你有所帮助。
https://stackoverflow.com/questions/957928
复制相似问题