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

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

    git-extras

    adds $ git root
    see https://github.com/tj/git-extras/blob/master/Commands.md#git-root

    $ pwd
    .../very-deep-from-root-directory
    $ cd `git root`
    $ git add . && git commit
    

    Availability of git-extras

    • homebrew(osx)/linuxbrew(linux) $ brew install git-extras
    • debian/ubuntu repos (https://packages.debian.org/sid/git-extras) $ apt-get install git-extras

提交回复
热议问题