Reputation: 17779
I created a new feature. I submitted it for code review, I was asked to split it into two pieces and then resubmit. The first piece, that I've now completed, is the new API. The second piece will be the integration of that new API into existing code. Here is what my git repo looks like currently:
o-o-A-o-o-o-o-o-o-o-o-o-o-B
| |
Original API with Feature
Feature Integration Removed
A
is the branch I was originally working on. B
is a branch I created wherein I removed the integration code and just left the API for the new feature.
I now want to restore the integration. Most of the intermediate steps between A
and B
are me deleting code that I now want to bring back.
To complicate the issue, the API did change a bit by the time B
was complete. I mostly want to restore A
so I can remember where in the code the new feature was integrated, and I can update things as needed.
Upvotes: 1
Views: 43
Reputation: 28228
From your description I think I would go either one of two ways. It depends on exactly what/how changes were done between A
and B
so it is hard to say what will work best without seeing the code.
Option one is to create a new branch (say C
) from A
and then cherry-pick the API changes you want from among the commits between A
and B
.
Option two is to undo all the deletions (that you now want back) between A
and B
. The very first thing is to create a backup branch so that no matter how you screw up, it is simple to rewind and start over again (e.g. git branch B.mybackup B
). Then do an interactive rebase (e.g. git checkout B; git rebase -i A
) where you remove the commits that delete the code you want back.
Upvotes: 1