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

前端 未结 17 1285
囚心锁ツ
囚心锁ツ 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:54

    This approach using git-remote worked well for me for HTTPS remotes:

    $ git remote -v | grep "(fetch)" | sed 's/.*\/\([^ ]*\)\/.*/\1/'
                                                    |  |        | |
                                                    |  |        | +---------------+
                                                    |  |        | Extract capture |
                                                    |  +--------------------+-----+
                                                    |Repository name capture|
                                                    +-----------------------+
    

    Example

提交回复
热议问题