Reputation: 177
I created a "branch_b" and ended up applying two commits. When i tried to merge with the master i realised that i haven't pulled my master since ages so there were so many conflicts (some of them irrelevant to my commits) to the point not worth resolving them (way too much effort).
What i want to do is to create a new "branch_X" from the updated master and apply the changes that i made on "branch_b".
Is it possible to achieve that?
I have tried:
cherry-pick the commits but when i try to apply them on branch_X i get the same conflicts when trying to merge "branch_b" to master. As stated previously, if i start resolving all the conflicts it would provably take up until year 2050.
Create a patch (using diff command) and tried to apply on "branxh_X". That one also failed with a simple message from git "error: patch failed:"
UPDATE1
So far any attempt resulted with conflicts which is something that i am trying to avoid.
Lets assume that i create a new branch and i start from the beginning making the same changes i did on branch_b "manually". Instead of doing this manually, is there anyway to do it via git? without rebasing or cherry-pick(those will create conflicts no matter what i try)?
Upvotes: 1
Views: 302
Reputation: 30307
That can be done like this:
git checkout --detach branch_b
git rebase --onto branch_X branch_X HEAD
That should apply the two revisions on top of branch_X..... but that will bring up just as many (if not more) conflicts. It's not like rebase can magically get rid of the conflicts. One general rule would say (and you can quote me on this): You could skip conflicts on rebase by merging.... it doesn't work the other way around
.
If you like the result after you rebase
git branch -f branch_b # ser branch_b on it's new position
Then push if/as needed
Upvotes: 2