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

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

    The man page for git-config (under Alias) says:

    If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command. [...] Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory.

    So, on UNIX you can do:

    git config --global --add alias.root '!pwd'
    

提交回复
热议问题