Serge
Serge

Reputation: 12344

rebasing part of an unrelated branch

I am playing with git-p4 sync. It does not work if I sync with ranges. As a result, i got an idea: sync into a separate branch and try to rebase it on the previously synced branch.

As a result, both branches are unrelated and the first commit of the second branch has the same contents as the top of the first branch;

                  ==
prev sync: |A1 A2 A3|
new sync:        |B1 B2 B3|
                  ==
                  B1 == A3

what i want to get at the end is

|A1 A2 A3 B2' B3'|

Any idea how to do it?

Upvotes: 1

Views: 65

Answers (1)

VonC
VonC

Reputation: 1323953

You can try a rebase --onto:

git checkout prev-sync
git rebase --onto pre-sync B1 new-sync

That should replay any commit after B1 up to new-sync HEAD onto prev-sync.

The OP Serge adds in the comments:

Somehow it created unexpected conflicts in creation of files.

So did a simple cherry-pick with options --keep-empty --strategy-option=theirs, needed to fully automate the process.
I also was able to do it with git cherry-pick B1..new-sync with the same extra qualifiers.

Upvotes: 1

Related Questions