Our integration platform ships to customers as versioned releases. Two weeks before each release we cut a branch from main, release/5.7 this time, and only fixes go onto it. When the release is out, we merge the release branch back into main so every fix made on it reaches the next version.
During testing of 5.7 we found that a new carrier routing feature mislabelled international parcels in one case. It was too late to fix safely, so the release manager reverted its merge commit on the release branch with git revert -m 1, and 5.7 shipped without it. The feature's team kept working on the fix on main.
After the release, we merged release/5.7 back into main as usual. Two days later the team merged their fix, and their tests failed with errors from classes that no longer existed. The feature had disappeared from main.
A revert is not a note saying leave this out of the release. It is an ordinary commit that deletes the changes, and Git merges it like any other. Main had not touched those lines since the branch was cut, so the merge applied the deletion cleanly, without a conflict, and the review of the merge back showed several thousand lines of diff that everybody expected to be large.
The obvious repair does not work either. The feature's original commits are already in main's history, so merging their branch again changes nothing, and Git reports it as up to date. As far as Git is concerned the feature was added and then deliberately removed. To bring it back, you revert the revert: git revert on the commit that the merge brought into main. That is what we did, and the team's fix went in on top of it the same afternoon.
The process changed in two places. A revert on a release branch is now done on a short branch with a name starting revert/, and the merge back into main is a pipeline step that lists every such revert it is about to bring in and stops until somebody decides for each one. Usually the answer is to revert it again on main straight after the merge.
Git records what was done to the code, not why. A revert made for one branch's reasons travels with every merge from that branch.
– Sergey Shinder