Mat*_*ley 660
您可以使用该命令获取任何已配置的远程URL的列表git remote -v.
这将为您提供以下内容:
base /home/***/htdocs/base (fetch)
base /home/***/htdocs/base (push)
origin git@bitbucket.org:*** (fetch)
origin git@bitbucket.org:*** (push)
Run Code Online (Sandbox Code Playgroud)
IQA*_*eas 56
如果您只需要远程存储库的名称(而不是任何其他数据),那么简单git remote就足够了.
$ git remote
iqandreas
octopress
origin
Run Code Online (Sandbox Code Playgroud)
aki*_*kim 30
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
...
Run Code Online (Sandbox Code Playgroud)
Dal*_*son 21
到目前为止的答案告诉你如何找到现有的分支:
git branch -r
Run Code Online (Sandbox Code Playgroud)
或者同一项目的存储库[见下面的注释]:
git remote -v
Run Code Online (Sandbox Code Playgroud)
还有另一种情况.您可能想知道托管在同一服务器上的其他项目存储库.
要发现该信息,我使用SSH或PuTTY登录到主机并ls查找包含其他存储库的目录.例如,如果我通过键入以下内容克隆了存储库:
git clone ssh://git.mycompany.com/git/ABCProject
Run Code Online (Sandbox Code Playgroud)
并想知道还有什么可用,我通过SSH或PuTTY登录git.mycompany.com并输入:
ls /git
Run Code Online (Sandbox Code Playgroud)
假设ls说:
ABCProject DEFProject
Run Code Online (Sandbox Code Playgroud)
我可以使用该命令
git clone ssh://git.mycompany.com/git/DEFProject
Run Code Online (Sandbox Code Playgroud)
获得访问其他项目的权限.
注意:通常
git remote只是告诉我origin- 我克隆项目的存储库.git remote如果你与两个或两个以上在同一个项目上工作的人合作并直接访问彼此的存储库而不是通过原点传递所有内容,那将会很方便.
小智 14
查看远程分支的简单方法是:
git branch -r
Run Code Online (Sandbox Code Playgroud)
要查看当地分支机构:
git branch -l
Run Code Online (Sandbox Code Playgroud)
这些方法都不能按照提问者所要求的方式工作,而我也经常需要这种方式。例如:
$ 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.
Run Code Online (Sandbox Code Playgroud)
这样做的全部目的是,除了远程用户和服务器之外,您没有任何信息,并且想要找出您有权访问的内容。
大多数答案假设您正在从 git 工作集中查询。提问者假设你不是。
作为一个实际示例,假设服务器上有一个存储库 foo.git。有人凭自己的智慧决定需要将其更改为 foo2.git。如果能列出服务器上的 git 目录,那就太好了。是的,我看到了 git 的问题。不过,如果有的话还是很高兴的。
| 归档时间: |
|
| 查看次数: |
347197 次 |
| 最近记录: |