11

I'm looking to have a branch in git that has 2 upstream branches, such that it pulls from both of them and pushes to one of them...

Here's the scenario:

MY_BRANCH --> ORIGINAL_BRANCH 
MY_BRANCH --> MY_BRANCH

So, my new branch, MY_BRANCH, pulls from both ORIGINAL_BRANCH and MY_BRANCH (at the origin), and pushes to MY_BRANCH (at the origin).

Is this possible in git?
I've added ORIGINAL_BRANCH as the upstream, so when I go git pull it pulls from it. And when I do git push it pushes to MY_BRANCH, which is good.
But how do I get it to follow MY_BRANCH as well, and pull from it too?
(reason for this is other developers might add something to it and not the ORIGINAL_BRANCH).

Any ideas?

zrrbite
  • 1,180
  • 10
  • 22
Jarrett
  • 1,767
  • 25
  • 47

1 Answers1

7

As mentioned in "How to track more than one remote with a given branch using Git?", you cannot register more than one upstream branch for a given local branch.

So you need to define an alias which will call git pull twice (with, for the second call, the MY_BRANCH from origin)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250