git – You asked me to pull without telling me which branch you want to merge with

Question:

TL;DR: I have a “tracked” branch that I can’t pull.

So here I am in “bucket-4”:

I’d like to pull in changes from my remote:

Hmm, odd, I thought I already added “bucket-4” as a tracking branch. Let’s see:

Indeed, bucket-4 is marked as “tracked”, yet somehow it’s configured for push, but not pull.

Looking at my .git/config file, I see that I have “remote” and “merge” entries for most of my branches, but not for bucket-4. How is it even considered “tracked” without this?

I see that the likely solution here is to add remote/merge entries for bucket-4 in my config file. But how is it considered “tracked” without this? bucket-4 was created locally, then pushed to the server from this repo, so I suspect that somehow I didn’t set up tracking properly for this branch.

Is there some configuration I can add in order to make all local branches track their remotes properly in the future?

Answer:

It says bucket-4 pushes to bucket-4 just because the default when pushing a branch is to push it to one with a matching name on the remote. (Note that this is still the default, even if the local branch is tracking a remote-tracking branch and the remote-tracking branch corresponds to a branch with a different name in the remote repository.)

The simplest way to set up the association between your bucket-4 and bucket-4 in origin is to make sure that the next time you push, you do:

Alternatively, you can do:


To answer a couple of your questions directly:

How is it even considered “tracked” without this?

In this case it isn’t – it’s not tracking the remote-tracking branch in any sense if there’s no branch.bucket-4.merge or branch.bucket-4.remote in your git config. The output from git remote show origin is just showing you where the branch would be pushed by default.

Is there some configuration I can add in order to make all local branches track their remotes properly in the future?

I don’t think that there is. When you created bucket-4 locally, as I assume happened, the remote-tracking branch didn’t exist, so it can’t be set up at that point – it would be very confusing default behaviour. You just need to remember to add -u to your first git push of that branch to its upstream repository.

I hope that’s of some help.

Leave a Reply