We discovered a serious issue with GIT at work today and I would like to know whether this is a bug or by design, and also, how to resolve this issue.
Consider the following sequence of events:
- Create Branch "test1" on Master
- Switch to Master:
- Edit a file and commit the change as commit "X"
- Switch to "test1":
- Cherry-pick commit "X" from Master
- Revert previous commit
- Merge Master into "test1"
Result: No merge conflict is reported even though the file has been edited in both branches, and even worse, the revert in step 3.2 did not survive, even though it was the most recent commit.
This is a huge problem, as can be seen by the following recent example: A colleague of mine had commited similar changes to different branches, noticed that parts of these changes were malicious and manually reverted parts of them on one of the branches because of that. After merging the branches, he was surprised to find out that his revert did not make it through the merge.
I uploaded a minimal example to google drive that demonstrates this issue. You can merge Master into test1 or vice versa, to see for yourself.
https://drive.google.com/drive/folders/19a-QPwOQKsn9PywUPd2DRnvUOml03nZ-?usp=sharing
If that's of any concern, I use TortoiseGIT 2.12.0.0 with Git for Windows 2.32.0.2.