create a new branch branch-c
reset it by git reset --hard origin/master
cherry-pick the commit from local branch-b
push it to review and it will be merged without dependecies. Then abandon the change coming from branch-b
.
Git+Gerrit: Merge two dependent branches with tree changes
-
29-09-2022 - |
Frage
I have master
and two branches: branch-a
and branch-b
. First contains some code changes, but remains on unchanged (old) files and folder structure. Second does not introduce any changes to code, but has a completely new file and folder structure.
What I did, was:
I did some changes to
branch-a
and commited them. Then I pushed them to Gerrit, but change wasn't reviewed yet, because it is unfinished.Then I did a serious structure change. But I mistakenly did it before switching to a new branch. Committing to
branch-a
seemed wrong to me. I wasn't able to checkoutmaster
, because git warned me about possible changes being overwritten and asked to either commit or stash.So, I created a new
branch-b
, commited all changes to it and pushed it to Gerrit. It was reviewed, but is now inSubmitted, Merge Pending
state, because it depends onbranch-a
, not reviewed yet.
How should I proceed now? Is there any way (in this scenario) to have changes from branch-a
merged to master
and remain on folder structure introduced with branch-b
?
I can't review and submit changes from branch-a
, because works over it hasn't been finished yet. (I think) I can't merge it to master on local side, because it has significant tree structure changes (old folder structure) and would overwrite everything, that was done later, with branch-b
. (I think) I can't merge branch-a
(code changes) to master
and then merge branch-b
(structure change) over it, cause I would end up with new files and folder structure, but old code (branch-b
would overwrite branch-a
).
What should I do now? How to clean this mess?
Lösung