Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i define multiple upstream branches for a local branch?

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?

like image 813
Jarrett Avatar asked Sep 20 '12 16:09

Jarrett


1 Answers

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)

like image 119
VonC Avatar answered Nov 02 '22 00:11

VonC