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

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

    Pre-Configured Shell Aliases in Shell Frameworks

    If you use a shell framework, there might already be a shell alias available:

    • $ grt in oh-my-zsh (68k) (cd $(git rev-parse --show-toplevel || echo "."))
    • $ git-root in prezto (8.8k) (displays the path to the working tree root)
    • $ g.. zimfw (1k) (changes the current directory to the top level of the working tree.)

提交回复
热议问题