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

前端 未结 17 1265
囚心锁ツ
囚心锁ツ 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条回答
  •  失恋的感觉
    2020-12-22 16:45

    In general, you cannot do this. Git does not care how your git repository is named. For example, you can rename directory containing your repository (one with .git subdirectory), and git will not even notice it - everything will continue to work.

    However, if you cloned it, you can use command:

    git remote show origin
    

    to display a lot of information about original remote that you cloned your repository from, and it will contain original clone URL.

    If, however, you removed link to original remote using git remote rm origin, or if you created that repository using git init, such information is simply impossible to obtain - it does not exist anywhere.

提交回复
热议问题