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

后端 未结 2 1592
情话喂你
情话喂你 2020-12-07 08:09

TL;DR: I have a \"tracked\" branch that I can\'t pull.

So here I am in \"bucket-4\":

$ git branch -v
  bucket-1       410f7b5 * gh-53 * gh-48 * \"Sha         


        
相关标签:
2条回答
  • 2020-12-07 08:47

    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:

    git push -u origin bucket-4
    

    Alternatively, you can do:

    git branch --set-upstream-to origin/bucket-4
    

    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.

    0 讨论(0)
  • 2020-12-07 08:54

    git branch --set-upstream <branch> origin/<branch> was deprecated at least as of 1.8.2.3 (my version).

    Use git branch --set-upstream-to=origin/<branch> <branch> instead.

    0 讨论(0)
提交回复
热议问题