git: a quick command to go to root of the working tree

前端 未结 7 1785
悲&欢浪女
悲&欢浪女 2020-12-24 01:21

I wanted a simple git command to go up to the \"root\" of the repository.

I started with a script, but figured that I cannot change active directory of the shell, I

7条回答
  •  死守一世寂寞
    2020-12-24 01:45

    Simpler still, steal from Is there a way to get the git root directory in one command? , and make an alias (as suggested by Peter) from

    cd "$(git rev-parse --show-toplevel)"
    

    This works whether you're in the root directory or not.

提交回复
热议问题