I have three branches first, second, and master:
D---E---F first
/
A---B---...---C---... master
\
G---H second
firstis a final version and is waiting to be merged intomasteras a single squashed commit.secondis still under development.
I want to regularly check if second merged with first will still work properly after new commits appear in second.
I have two repositories:
- At
repo1I simply add new commitsIandJtosecondand push them toorigin. - At
repo2my working branch issecond, which has been rebased ontofirst. I am never going to push it at all,repo2is needed only for local build checks.
repo1
D---E---F first
/
A---B---...---C---... master
\
G---H---I---J second, origin/second
repo2
$ git checkout second
$ git rebase first
D---E---F first
/
A---B---...---C---... master
\
D'--E'--F'--B'--...---C'--G---H second
The important thing is that commit E(E') causes a long-time rebuild of the whole project, so I want it to never be reapplied again and stay where it is.
That's why I can't use:
git pull -r
on second because it would rearrange all commits and result in this
repo2
A---B---...---C---G---H---I---J---D'--E'--F' second
Also, I can't use fast-forwarded pull because second in repo2 and origin/second diverge. But my guess is that something like fast-forwarded pull is indeed possible. It should result in the following:
repo2
D---E---F first
/
A---B---...---C---... master
\
D'--E'--F'--B'--...---C'--G---H---I---J second
Can I somehow imitate it with some sequence of Git commands?
From your
repo2: you can check the state oforigin1/second, then rungit fetch, check the new state and try to cherry-pick the delta :If you need this to work not just with a hard coded
secondbranch but for any active branch you may have :or if you want to pass the branch to fetch as an argument :
or ...