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

前端 未结 7 1804
悲&欢浪女
悲&欢浪女 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:49

    This has been asked before, Is there a way to get the git root directory in one command? Copying @docgnome's answer, he writes

    cd $(git rev-parse --show-cdup)
    

    Make an alias if you like:

    alias git-root='cd $(git rev-parse --show-cdup)'
    

提交回复
热议问题