Git 存储库的远程列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10183724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
List of remotes for a Git repository?
提问by priestc
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?
我有一个 Git 存储库。这个存储库有多个远程存储库(我认为)。如何获取属于所述存储库的远程存储库的列表?
Like git list --remotes
or something like that?
像git list --remotes
或类似的东西?
回答by Matthew Scharley
You can get a list of any configured remote URLs with the command git remote -v
.
您可以使用命令获取任何配置的远程 URL 的列表git remote -v
。
This will give you something like the following:
这将为您提供如下内容:
base /home/***/htdocs/base (fetch)
base /home/***/htdocs/base (push)
origin [email protected]:*** (fetch)
origin [email protected]:*** (push)
回答by IQAndreas
If you only need the names of the remote repositories (and not any of the other data), a simple git remote
is enough.
如果您只需要远程存储库的名称(而不是任何其他数据),一个简单的git remote
就足够了。
$ git remote
iqandreas
octopress
origin
回答by akim
FWIW, I had exactly the same question, but I could not find the answer here. It's probably not portable, but at least for gitolite, I can run the following to get what I want:
FWIW,我有完全相同的问题,但我在这里找不到答案。它可能不是便携式的,但至少对于 gitolite,我可以运行以下命令来获得我想要的:
$ ssh [email protected] 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
...
回答by Dale Wilson
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 PuTTYto log into to host and ls
to find the directories containing the other repositories. For example, if I cloned a repository by typing:
为了发现这些信息,我使用 SSH 或PuTTY登录到主机并ls
查找包含其他存储库的目录。例如,如果我通过键入以下内容克隆了一个存储库:
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:
并想知道还有什么可用的,我通过 SSH 或 PuTTY 登录到 git.mycompany.com 并键入:
ls /git
assuming ls
says:
假设ls
说:
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 aboutorigin
-- 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.
注意:通常
git remote
只是告诉我origin
-我从中克隆项目的存储库。git remote
如果您与从事同一项目的两个或更多人合作并直接访问彼此的存储库而不是通过 origin 传递所有内容,那将会很方便。
回答by Andy Seitz
A simple way to see remote branches is:
查看远程分支的简单方法是:
git branch -r
To see local branches:
查看当地分行:
git branch -l