0

What would be the consequences of reverting the original commit while the same had been cherry-picked to the target branch?

There is a branch (say feature) with some changes (commit: A), while this change was expected to be in another branch (say integration).
So, I cherry-picked this change (commit: A) from feature branch to integration branch (resulting into a new commit: AC, in integration branch).

However, due to testing needs, the feature branch is not expected to contain this change (commit: A) at all.
Hence, I had to revert A from the feature branch (resulting in a revert commit AR, in the feature branch).

Now, if later I merge this feature branch into the integration branch, would there be any issues or conflicts in the changes that had been cherry-picked initially.
[After this merge, integration will have all the 3 commits, viz. A, AR, AC]
The commit AR will nullify the commit A, won't it nullify the commit AC too?

Satyendra
  • 1,635
  • 3
  • 19
  • 33
  • The changes from commit AC in the integration branch could very well vanish when feature is merged into it. But, even if that happens, it would be easy for you to bring them back. – Tim Biegeleisen Jul 10 '18 at 07:17

1 Answers1

1

No, it should be fine. AR will only revert A's changes then AC will reinstall them.

Also to note : you could have considered resetting to the commit just before A (git reset --hard A^) instead of reverting it, but I guess it's heavily depending on the specifics of your situation, and maybe a bit on workflow style choices.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • I'm not sure things will play out the way you describe. – Tim Biegeleisen Jul 10 '18 at 07:16
  • @TimBiegeleisen A and AC feature the same changes. How would this fail? I'm pretty sure I had the same case recently and it went great. What am I missing? – Romain Valeri Jul 10 '18 at 07:18
  • The feature branch contains instructions which revert some changes. During a merge, these get played on the target branch. Just because you saw this go a certain way does not necessarily mean anything for the OP's situation. – Tim Biegeleisen Jul 10 '18 at 07:19
  • @TimBiegeleisen I agree to that, I was not trying to apply blindly the solution to another problem. But I admit I don't see the problem you seem to be hinting at so far, and of course I'd like to spot the errors or bad assumptions I made. – Romain Valeri Jul 10 '18 at 07:24