git revert lost some changes

0

I got some problem by using git revert, below is my situation:

For example, I have a file named a.txt, and I added two lines to it (m1), and merged to mainline. And then some other commits merged to mainline which modify the same file (a.txt), after few days, I realized my change to a.txt was wrong, then I revert the m1 (delete two lines), and merged to mainline (w1), but the fact is the two lines which I removed were still there, I don't know why.

It seems that w1 has two parents, and the two parents both changed the a.txt, then git merge two changes and reserve the two lines which I wanted to delete.

And I want to know how to avoid this, and is there any way to disable revert both from Gerrit UI and git command line?

user1086979

Posted 2019-09-10T01:20:39.920

Reputation: 1

No answers