Cherry-pick ALL commits from a branch in one go via filter on branch
Hi,
Recently I've found myself stumbling in this situation:
I was working on feature A.
While I was working on A, a new feature B was requested.
Being as B was heavily dependent on A's code I created feature B branch directly from A.
I've worked on both in parallel.
Since A was being tested at the time (which meant committing some bugfixes from time to time) I've kept merging it into B on a daily basis to keep B aligned and avoid conflicts in the future.
After a while I completed A which was then merged into master via Squash.
This is when I've found myself in a bit of a pickle.
Due to how squash works, merging master into B would now cause the same conflicts I thought I was avoiding by diligently keeping B aligned with A.
At this point I had 2 options:
1- solving conflicts in branch B AND keeping all commits from branch A.
2- create a 3rd branch C from Master and cherry-pick there all commits belonging specifically to branch B (in other words, ignoring all commits from branch A since all its changes were now in master albeit via the squash commit).
Now, the problem was that cherry-picking all intertwined commits from branch B was gonna be very tedious and error-prone. (they were a lot and mixed with A bugfixing commits)
From what I understand there are a combination of git commands to sort of achieve this result but of course I couldn't test it at work and had little time to test at home, hence my feature request here today (which I can confidently study and understand once implemented by git experts).
Customer support service by UserEcho
Unfortunately I used merge as I was unfamiliar with rebase and was in a bit of hurry. (Lame excuse, I know. I'll make it a point to study rebase in detail)
Just to confirm, are you saying that using rebase at all times to keep B aligned with A would have kept me from getting into this messy situation? (at least in this particular case where I was developing B on top of A)
If so, and if my feature request is now effectively useless I apologize for wasting your time (I didn't mean to) and I thank you for your tip.
With rebase, I would say, there would not have been a problem. Maybe it just is my limited understanding, but I don't see any reasonable use-case for merging into a feature branch.