I am attempting to reconcile two feature branches in git. Automerging is problematic, as the functionality of both of these features cannot coexist. For context, the scenario is like this:
------------- Feature A
/ \
------------------------- Main
\ /
----- Feature B
Feature A split from Main, and we knew it would take a while to implement. Soon after, we split Feature B to develop it as a stop-gap until Feature A is ready. It implements similar functionality in a different way, and cannot coexist with Feature A. Since Feature B was merged back into Main, necessary commits have occurred on Main that Feature A also needs (otherwise I would just force push the tip of Feature A as the new tip of Main). Note that the nature of incompatibility between the branches is not something git could recognize; it's not conflicting lines of code, but rather separate lines of code using the same resources.
I found this answer as the most straightforward solution, but the consensus there seems to be that this is indicative of a bad workflow or bad practice. How would you handle this situation instead?
CodePudding user response:
You could merge Main into Feature A first.
Then, do the clean up (i.e. removal of Feature B stuff there) on the Feature A branch.
Then, you can merge Feature A into Main "safely".
git revert might be your friend when working on Feature A after merging Main into it.
Alternatively, if you don't want to do the clean up on Feature A, you can branch off of Feature A before (see Replace_B_by_A below).
e.g.
git checkout Feature_A
git checkout -b Replace_B_by_A
git merge Main
# fix commits, e.g. by using `git revert`
git checkout Main
git merge Replace_B_by_A
