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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With