List of remotes for a Git repository?

后端 未结 6 1487
攒了一身酷
攒了一身酷 2020-12-07 07:07

I have a Git repository. This repository has multiple remote repositories (I think). How can I get a list of the remote repositories that belong to said repository?

6条回答
  •  长情又很酷
    2020-12-07 07:11

    The answers so far tell you how to find existing branches:

    git branch -r
    

    Or repositories for the same project [see note below]:

    git remote -v
    

    There is another case. You might want to know about other project repositories hosted on the same server.

    To discover that information, I use SSH or PuTTY to log into to host and ls to find the directories containing the other repositories. For example, if I cloned a repository by typing:

    git clone ssh://git.mycompany.com/git/ABCProject
    

    and want to know what else is available, I log into git.mycompany.com via SSH or PuTTY and type:

    ls /git
    

    assuming ls says:

     ABCProject DEFProject
    

    I can use the command

     git clone ssh://git.mycompany.com/git/DEFProject
    

    to gain access to the other project.

    NOTE: Usually git remote simply tells me about origin -- the repository from which I cloned the project. git remote would be handy if you were collaborating with two or more people working on the same project and accessing each other's repositories directly rather than passing everything through origin.

提交回复
热议问题