git 您的配置指定与远程的 <branch name> 合并,但未获取此类引用。?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36984371/
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
Your configuration specifies to merge with the <branch name> from the remote, but no such ref was fetched.?
提问by Farrukh Chishti
I am getting this error for pull:
我收到这个错误拉:
Your configuration specifies to merge with the ref 'refs/heads/feature/Sprint4/ABC-123-Branch' from the remote, but no such ref was fetched.
您的配置指定与来自远程的 ref 'refs/heads/feature/Sprint4/ABC-123-Branch' 合并,但未获取此类 ref。
This error is not coming for any other branch.
The special thing about this branch is that it is created from the previous commit of another branch.
My config file looks like:
任何其他分支都不会出现此错误。
这个分支的特别之处在于它是从另一个分支的先前提交创建的。
我的配置文件看起来像:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = <url here>
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "new-develop"]
remote = origin
merge = refs/heads/new-develop
[branch "feature/Sprint4/ABC-123-Branch"]
remote = origin
merge = refs/heads/feature/Sprint4/ABC-123-Branch
采纳答案by torek
What this means
这意味着什么
Your upstream—the remote you call origin
—no longer has, or maybe never had (it's impossible to tell from this information alone) a branch named feature/Sprint4/ABC-123-Branch
. There's one particularly common reason for that: someone (probably not you, or you'd remember) deleted the branch in that other Git repository.
你的上游——你调用的远程origin
——不再有,或者可能从来没有(单凭这些信息是不可能知道的)一个名为feature/Sprint4/ABC-123-Branch
. 有一个特别常见的原因:有人(可能不是你,或者你记得)删除了另一个 Git 存储库中的分支。
What to do
该怎么办
This depends on what you want. See the discussion section below. You can:
这取决于你想要什么。请参阅下面的讨论部分。你可以:
- create or re-create the branch on the remote, or
- delete your local branch, or
- anything else you can think of.
- 在远程创建或重新创建分支,或
- 删除您的本地分支,或
- 你能想到的其他任何东西。
Discussion
讨论
You must be running git pull
(if you were running git merge
you would get a different error message, or no error message at all).
您必须正在运行git pull
(如果您正在运行,git merge
您会收到不同的错误消息,或者根本没有错误消息)。
When you run git fetch
, your Git contacts another Git, based on the url
line in under the [remote "origin"]
section of your configuration. That Git runs a command (upload-pack
) that, among other things, sends yourGit a list of all branches. You can use git ls-remote
to see how this works (try it, it is educational). Here is a snippet of what I get when running this on a Git repository for git
itself:
当您运行 时git fetch
,您的 Git 会根据配置部分url
下的行与另一个 Git 联系[remote "origin"]
。Git 运行一个命令 ( upload-pack
),除其他外,它会向您的Git发送所有分支的列表。您可以使用它git ls-remote
来查看它是如何工作的(尝试一下,它具有教育意义)。这是我在 Git 存储库上为git
自己运行时得到的片段:
$ git ls-remote origin
From [url]
bbc61680168542cf6fd3ae637bde395c73b76f0f HEAD
60115f54bda3a127ed3cc8ffc6ab6c771cbceb1b refs/heads/maint
bbc61680168542cf6fd3ae637bde395c73b76f0f refs/heads/master
5ace31314f460db9aef2f1e2e1bd58016b1541f1 refs/heads/next
9e085c5399f8c1883cc8cdf175b107a4959d8fa6 refs/heads/pu
dd9985bd6dca5602cb461c4b4987466fa2f31638 refs/heads/todo
[snip]
The refs/heads/
entries list all of the branches that exist on the remote,1along with the corresponding commit IDs (for refs/tags/
entries the IDs may point to tag objects rather than commits).
这些refs/heads/
条目列出了远程存在的所有分支,1以及相应的提交 ID(对于refs/tags/
条目,ID 可能指向标记对象而不是提交)。
Your Git takes each of these branch names and changesit according to the fetch
line(s) in that same remote
section. In this case, your Git replaces refs/heads/master
with refs/remotes/origin/master
, for instance. Your Git does this with every branch name that comes across.
您的 Git 使用这些分支名称中的每一个,并根据同一部分中的行进行更改。在这种情况下,你的Git替代用,例如。您的 Git 会使用遇到的每个分支名称执行此操作。fetch
remote
refs/heads/master
refs/remotes/origin/master
It also records the original names in the special file FETCH_HEAD
(you can see this file if you peek into your own .git
directory). This file saves the fetched names and IDs.
它还将原始名称记录在特殊文件中FETCH_HEAD
(如果您查看自己的.git
目录,则可以看到该文件)。此文件保存获取的名称和 ID。
The git pull
command is meant as a convenience short cut: it runs git fetch
on the appropriate remote, and then git merge
(or, if so instructed, git rebase
) with whatever arguments are needed to merge (or rebase) as directed by the [branch ...]
section. In this case, your [branch "feature/Sprint4/ABC-123-Branch"]
section says to fetch from origin
, then merge with whatever ID was found under the name refs/heads/feature/Sprint4/ABC-123-Branch
.
该git pull
命令是一个方便的捷径:它git fetch
在适当的遥控器上运行,然后git merge
(或者,如果有指示,git rebase
)使用任何需要的参数来按照该[branch ...]
部分的指示进行合并(或变基)。在这种情况下,您的[branch "feature/Sprint4/ABC-123-Branch"]
部分说从 获取origin
,然后与名称下找到的任何 ID 合并refs/heads/feature/Sprint4/ABC-123-Branch
。
Since nothing was found under that name, git pull
complains and stops.
由于在该名称下没有发现任何内容,因此git pull
抱怨并停止。
If you ran this as two separate steps, git fetch
and then git merge
(or git rebase
), your Git would look at your cached remotes/origin/
remote-tracking branches to see what to merge with or rebase onto. If there wassuch a branch at one time, you may still have the remote-tracking branch. In this case you would not get an error message. If there was never such a branch, or if you have run git fetch
with --prune
(which removes dead remote-tracking branches), so that you have no corresponding remote-tracking branch, you would get a complaint, but it would refer to origin/feature/Sprint4/ABC-123-Branch
instead.
如果您将其作为两个单独的步骤运行,git fetch
然后git merge
(或git rebase
),您的 Git 将查看您缓存的remotes/origin/
远程跟踪分支,以查看要合并或变基的内容。如果是在同一时间这样的一个分支,你仍然可以拥有远程跟踪分支。在这种情况下,您不会收到错误消息。如果从来没有这样的分支,或者如果您运行git fetch
with --prune
(删除死的远程跟踪分支),因此您没有相应的远程跟踪分支,您会收到投诉,但它会origin/feature/Sprint4/ABC-123-Branch
改为引用。
In either case, we can conclude that feature/Sprint4/ABC-123-Branch
does not exist now on the remote named origin
.
在任何一种情况下,我们都可以得出结论,feature/Sprint4/ABC-123-Branch
远程命名现在不存在origin
。
It probably did exist at one time, and you probably created your local branch from the remote-tracking branch. If so, you probably still have the remote-tracking branch. You might investigate to see who removed the branch from the remote, and why, or you might just push something to re-create it, or delete your remote-tracking branch and/or your local branch.
它可能曾经存在过,并且您可能从远程跟踪分支创建了本地分支。如果是这样,您可能仍然拥有远程跟踪分支。您可能会调查以查看谁从远程删除了分支以及原因,或者您可能只是推送某些内容来重新创建它,或者删除您的远程跟踪分支和/或您的本地分支。
1Well, all that it is going to admitto, at least. But unless they have specifically hidden some refs, the list includes everything.
1好吧,至少它会承认所有这些。但是除非他们特别隐藏了一些参考文献,否则该列表包含所有内容。
回答by Extreme
This can also happen if you/someone renamed the branch.
So follow these steps (if you know that branch name is renamed)
Assuming earlier branch name as wrong-branch-name
and someone renamed it to correct-branch-name
So.
如果您/某人重命名了分支,也会发生这种情况。因此,请按照以下步骤操作(如果您知道分支名称已重命名)假设较早的分支名称为Aswrong-branch-name
并且有人将其重命名为correct-branch-name
So。
git checkout correct-branch-name
git pull
(you'll see this "Your configuration specifies..")
git pull
(您会看到“您的配置指定..”)
git branch --unset-upstream
git push --set-upstream origin correct-branch-name
git push --set-upstream origin correct-branch-name
git pull
(you'll not get the earlier message )
git pull
(你不会收到之前的消息)
回答by Malhaar Punjabi
Check if your remote branch is available to pull. I had the same issue, finally realized the remote branch was deleted by someone.
检查您的远程分支是否可以拉取。我有同样的问题,终于意识到远程分支被某人删除了。
回答by nicko
For me it was a case sensitivity issue. My local branch was Version_feature2 instead of Version_Feature2. I re-checked out my branch using the correct casing and then git pull worked.
对我来说,这是一个区分大小写的问题。我的本地分支是 Version_feature2 而不是 Version_Feature2。我使用正确的大小写重新检查了我的分支,然后 git pull 工作了。
回答by Nicola Gallazzi
In my case I was simply lacking of initial commit on remote branch, so local branch wasn't finding anything to pull and it was giving that error message.
在我的情况下,我只是缺乏远程分支上的初始提交,所以本地分支没有找到任何要拉的东西,它给出了错误消息。
I did:
我做了:
git commit -m 'first commit' // on remote branch
git pull // on local branch
回答by akgupta
This error can also be received when the origin branch name has some case issue.
当源分支名称有一些大小写问题时,也会收到此错误。
For example: origin branch is team1-Team
and the local branch has been checkout as team1-team
. Then, this T
in -Team
and t
in -team
can cause such error. This happened in my case. So, by changing the local name with the origin branch's name, the error was solved.
例如: origin 分支 isteam1-Team
并且本地分支已 checkout as team1-team
。然后,这个T
in-Team
和t
in-team
会导致这样的错误。这发生在我的情况下。因此,通过使用原始分支的名称更改本地名称,解决了错误。
回答by user1747134
I got a similar error when the actual cause was that my disk was full. After deleting some files, git pull
began to work as I expected.
当实际原因是我的磁盘已满时,我遇到了类似的错误。删除一些文件后,git pull
开始按我的预期工作。
回答by Stéphane
I kept running into this issue. In my case, @Jerreck's comment about case differences in the branch names was the cause of this error. Some Windows tools aren't aware of case sensitivity.
我一直遇到这个问题。就我而言,@Jerreck 关于分支名称中大小写差异的评论是导致此错误的原因。某些 Windows 工具不知道区分大小写。
To turn off case-sensitivity in git, run this command:
要在 git 中关闭区分大小写,请运行以下命令:
git config --global core.ignorecase true
Note that this will impact more than branch names. For example, if you have "Foo.h" and "foo.h" in the same directory (not a great idea when building software for Windows) then I suspect you cannot turn off case sensitivity.
请注意,这不仅会影响分支名称。例如,如果您在同一目录中有“Foo.h”和“foo.h”(在为 Windows 构建软件时不是一个好主意),那么我怀疑您无法关闭区分大小写。
回答by AB Abhi
Just check if someone deleted the branch at remote.
只需检查是否有人远程删除了分支。
回答by Guilherme Campos Hazan
In my case, i had deleted the original branch from which my current branch derived from. So in the .git/config file i had:
就我而言,我已经删除了我当前分支所源自的原始分支。所以在 .git/config 文件中我有:
[branch "simil2.1.12"]
remote = origin
merge = refs/heads/simil2.0.5
rebase = false
the simil2.0.5 was deleted. I replaced it with the same branch name:
simil2.0.5 被删除。我用相同的分支名称替换它:
[branch "simil2.1.12"]
remote = origin
merge = refs/heads/simil2.1.12
rebase = false
and it worked
它起作用了