When I try to create a new branch tracking a remote branch, I get this:
$ git branch -t test origin/foo
error: Not tracking: ambiguous information for ref refs/r
because it finds less than one
Nope: because it finds more than one matching remote branch, which means the function remote_find_tracking()
returns more than one tracking branch for a given local branch ref.
Is some_remote_branch
not already tracked by one of your local branches?
(a git config -l
would allow you to check what you have currently have set up).
(a git branch -r
can also help to list your current remote-tracking branches. )
remote branches, which I thought are something different that remote-tracking branches.
Wrong, as illustrated by this thread:
remote-branches are the "real" remote-tracking-branches. You don't commit to them locally, they are essentially read-only copies of exactly what is happening in a remote repository.
If you try to 'git-checkout' a remote-tracking branch, you will get a detached HEAD.Local branch:
A branch to which you may commit changes. Optionally, the branch can be configured to "follow" one of your remote-tracking branches. This means that a 'git-pull
' without arguments (when your local branch is checked out), will automatically 'git-fetch
' and then 'git-merge
' the remote-tracking branch.
Now:
it's the job of
git-fetch
to update remote-tracking branches with any changes found in the remote repository.
Git-pull
runsgit-fetch
and then runs agit-merge
to update the currently-checked-out branch.
The problem is, for git-merge:
When this happens,
git-merge
must decide whichremote-tracking-branch
to merge into the currently checked out local branch.
You can set whichremote-tracking-branch
will be selected in this situation with the --track option.
--track
sets up a local following branch to refer to a remote's branch, not to the tracking branch
Consider that remote_find_tracking()
takes a single remote and a refspec with src filled, and returns the given refspec after filling its dst, if an appropriate tracking was configured for the remote, meaning git.
/*
* For the given remote, reads the refspec's src and sets the other fields.
*/
int remote_find_tracking(struct remote *remote, struct refspec *refspec);
May be it considers it already has a local following branch matching some_remote_branch
. Do you have any local branch with that exact same name?
Or, the other way around: your current branch has a remote branch with a similar name, which makes it a natural candidate for any git-merge
: trying to make it track another remote branch would make the git-merge
unable to choose which local branch to update/merge with changes of a remote.