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

前端 未结 22 1239
被撕碎了的回忆
被撕碎了的回忆 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

    alias git-root='cd \`git rev-parse --git-dir\`; cd ..'
    

    Everything else fails at some point either going to the home directory or just miserably failing. This is the quickest and shortest way to get back to the GIT_DIR.

提交回复
热议问题