How do you get the Git repository's name in some Git repository?

前端 未结 17 1304
囚心锁ツ
囚心锁ツ 2020-12-22 16:18

When you are working in some Git directory, how can you get the Git repository name in some Git repository? Are there any Git commands?

# I did check out bar         


        
17条回答
  •  猫巷女王i
    2020-12-22 16:50

    Well, if, for the repository name you mean the Git root directory name (the one that contains the .git directory) you can run this:

    basename `git rev-parse --show-toplevel`
    

    The git rev-parse --show-toplevel part gives you the path to that directory and basename strips the first part of the path.

提交回复
热议问题