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.
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
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.
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).
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 your Git 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 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,1 along with the corresponding commit IDs (for refs/tags/
entries the IDs may point to tag objects rather than commits).
Your Git takes each of these branch names and changes it 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.
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.
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
.
Since nothing was found under that name, git pull
complains and stops.
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 was such 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.
In either case, we can conclude that feature/Sprint4/ABC-123-Branch
does not exist now on the remote named 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 admit to, at least. But unless they have specifically hidden some refs, the list includes everything.
Check if your remote branch is available to pull.
I had the same issue, finally realized the remote branch was deleted by someone.
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.
git checkout correct-branch-name
git pull
(you'll see this "Your configuration specifies..")
git branch --unset-upstream
git push --set-upstream origin correct-branch-name
git pull
(you'll not get the earlier message )
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.
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.
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.
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
Just check if someone deleted the branch at remote.
For me this happened because i merged a branch dev into master using web interface and then tried to sync/pull using VSCode which was open on dev branch.(its weird that i could not change to master without getting this error.)
git pull
Your configuration specifies to merge with the ref 'refs/heads/dev'
from the remote, but no such ref was fetched.'
It makes sense that is not finding it refs/heads/dev - for me it was easier to just delete the local folder and clone again.
I just got exactly this error when doing "git pull" when my disk was full. Created some space and it all started working fine again.
You can edit the ~/.gitconfig
file in your home folder. This is where all --global settings are saved.
Or, use git config --global --unset-all remote.origin.url
and after run git fetch
with repository url.
If another pull just works, it means your internet wasn't connected.