我有一个Git存储库。这个存储库有多个远程存储库(我认为)。如何获得属于该存储库的远程存储库的列表?
比如git列表,遥控器之类的?
我有一个Git存储库。这个存储库有多个远程存储库(我认为)。如何获得属于该存储库的远程存储库的列表?
比如git列表,遥控器之类的?
当前回答
查看远程分支的简单方法是:
git branch -r
查看本地分支机构:
git branch -l
其他回答
您可以使用命令git remote -v获取任何已配置的远程url的列表。
这将为您提供如下内容:
base /home/***/htdocs/base (fetch)
base /home/***/htdocs/base (push)
origin git@bitbucket.org:*** (fetch)
origin git@bitbucket.org:*** (push)
FWIW,我也有同样的问题,但我在这里找不到答案。它可能是不可移植的,但至少对于gitolite,我可以运行以下命令来得到我想要的:
$ ssh git@git.xxx.com info
hello akim, this is gitolite 2.3-1 (Debian) running on git 1.7.10.4
the gitolite config gives you the following access:
R W android
R W bistro
R W checkpn
...
这些方法都不能满足提问者的要求,而这也是我经常需要的。例如:
$ git remote
fatal: Not a git repository (or any of the parent directories): .git
$ git remote user@bserver
fatal: Not a git repository (or any of the parent directories): .git
$ git remote user@server:/home/user
fatal: Not a git repository (or any of the parent directories): .git
$ git ls-remote
fatal: No remote configured to list refs from.
$ git ls-remote user@server:/home/user
fatal: '/home/user' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这样做的关键是你没有任何信息 远程用户和服务器,并想知道您可以访问什么。
大多数答案都假设您在git工作集中进行查询。 提问者是在假设你不是。
作为一个实际示例,假设有一个存储库foo。服务器上的Git。 聪明的人决定把它改成foo2.git。它将 在服务器上创建一个git目录列表非常好。是的,我明白了 git的问题。如果有的话还是很不错的。
如果您只需要远程存储库的名称(而不需要任何其他数据),那么一个简单的git远程就足够了。
$ git remote
iqandreas
octopress
origin
查看远程分支的简单方法是:
git branch -r
查看本地分支机构:
git branch -l