在git中获取并不能获取所有分支 [英] fetch in git doesn't get all branches

查看:286
本文介绍了在git中获取并不能获取所有分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经克隆了一个存储库,然后其他人创建了一个新分支,我想开始该分支。我阅读了手册,看起来很简单。奇怪的是,它不起作用,而且我发现的所有帖子都表明我在做正确的事。因此,我将自己置于沉重打击之下,因为这必须显然有问题:

I have cloned a repository, after which somebody else has created a new branch, which I'd like to start working on. I read the manual, and it seems dead straight easy. Strangely it's not working, and all the posts I've found suggest I'm doing the right thing. So I'll subject myself to the lambasting, because there must be something obviously wrong with this:

正确的动作似乎成为

git fetch
git branch -a
* master
  remotes/origin/HEAD --> origin/master
  remotes/origin/master
git checkout -b dev-gml origin/dev-gml

这时出现了问题,由于某些原因,在 git fetch 之后,我看不到dev-gml远程分支。为什么不?如果我是从新克隆存储库的,则在那里,因此肯定存在远程分支:

At this point there is a problem, for some reason after git fetch I can't see the dev-gml remote branch. Why not? If I clone the repository freshly, it's there, so certainly the remote branch exists:

$ mkdir ../gitest
$ cd ../gitest
$ git clone https://github.com/example/proj.git
Cloning into proj...
remote: Counting objects: 1155, done.
remote: Compressing objects: 100% (383/383), done.
remote: Total 1155 (delta 741), reused 1155 (delta 741)
Receiving objects: 100% (1155/1155), 477.22 KiB | 877 KiB/s, done.
Resolving deltas: 100% (741/741), done.
$ cd projdir
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev-gml
  remotes/origin/master

我尝试过 git update git pull git fetch --all ,请在所有可能的排列中 git漂亮 ...

I've tried git update, git pull, git fetch --all, git pretty-please in all possible permutations...

推荐答案

检查 remote.origin.fetch 设置

时,可以看到问题(以 $
是带有我键入的命令的bash提示。其他行是结果输出)

The problem can be seen when checking the remote.origin.fetch setting
(The lines starting with $ are bash prompts with the commands I typed. The other lines are the resulting output)

$ git config --get remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master

如您所见,就我而言,远程设置为专门且仅获取master分支。我按照下面的方法修复了它,包括第二条命令来检查结果。

As you can see, in my case, the remote was set to fetch the master branch specifically and only. I fixed it as per below, including the second command to check the results.

$ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
$ git config --get remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*

通配符 * 当然意味着该路径下的所有内容。

The wildcard * of course means everything under that path.

不幸的是,我看到了这条评论,我已经仔细研究并通过反复试验找到了答案。

Unfortunately I saw this comment after I had already dug through and found the answer by trial and error.

这篇关于在git中获取并不能获取所有分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆