Is there a way to get the git root directory in one command?

前端 未结 22 1032
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 09:57

Mercurial has a way of printing the root directory (that contains .hg) via

hg root

Is there something equivalent in git to get the director

22条回答
  •  遇见更好的自我
    2020-11-22 10:43

    If you're looking for a good alias to do this plus not blow up cd if you aren't in a git dir:

    alias ..g='git rev-parse && cd "$(git rev-parse --show-cdup)"'
    

提交回复
热议问题