Your configuration specifies to merge with the <branch name> from the remote, but no such ref was fetched.?
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.
Edit, Jul 2020: There's a new fetch protocol that can avoid listing everything, and only list names that your Git says it's looking for. This can help with repositories that have huge numbers of branches and/or tags. However, if your Git is interested in all possible names, you'll still get all the names here.
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 )
Check if your remote branch is available to pull. I had the same issue, finally realized the remote branch was deleted by someone.