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

前端 未结 22 1235
被撕碎了的回忆
被撕碎了的回忆 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条回答
  •  旧时难觅i
    2020-11-22 10:53

    Just in case if you're feeding this path to the Git itself, use :/

    # this adds the whole working tree from any directory in the repo
    git add :/
    
    # and is equal to
    git add $(git rev-parse --show-toplevel)
    

提交回复
热议问题