Realized that this seems a question next to What are different about Revert command among of popup menu, git menu and Show History in Android Studio 3.3?, I am not sure if I had something wrong with my answer there.
A: I can't understand why the following code is displayed when I do Revert operation? It seem that the system ready all history commit records to let me merge.
This is called a Merge Conflict. It happens when two commits are going to merge but they have found editing the same place with different idea, which makes Git unable to decide which one to keep. Then Git keeps those both, shown with the format:
<<<<<<< Branch1
Content A
=======
Content B
>>>>>>> Branch2
And let you manually decide which one to keep.
B: And more, I can't get the correct result (rollback my code to the point Submit 2) no matter I choice Accept Yours, Accept Theirs or Merge... command, why?
Then I found my answer there is wrong. I am going to modify it later.
When you want to revert the repository to the time when you made Submit 2, you should select the child commit of Submit 2, which is Submit 3 in your case, then use "Theirs" to merge.
Why Submit 3? That is because, the Revert
"Produce a new commit, which reverts the changes made in the original commit", then when you revert Submit 3, it will clear what you have done after (and include) Submit 3, which is just what the repository looks like when you made Submit 2.
Why "Theirs"? Here, if you select Submit 2, then the commit is at Submit 2, "Our changes" is Submit 3 (what we have done after Submit 2), and "Their changes" is Submit 1 (why? we want to revert (cancel) what we have done in Submit 2, then the repository is becoming what it looks like before Submit 2, that is Submit 1).
Why conflict? Submit 3 and Submit 1 have changed the same line with different idea, then a conflict occurs.
...Wait, at the time I am testing, I think I have found a bug of Local Changes
or Changelist
in IntelliJ IDEA... Yes, this have been reported many times, with different reproduction method, for example IDEA-124412, IDEA-67036 and IDEA-20326, that a file modified twice with different method has shown in the changelist thought the second modification have reverted the first modification.
C: What will the system do if I launch Merge... operation?
When you click Merge...
, then you can see the window shown in the last picture of your question. This window allows you to do an interactive merging. There are "X" and ">>" or "<<" icon shown near the line numbers that have conflict in the both sides of window. Click "X" means you reject that piece of code in that side, click ">>" or "<<" means you accept that piece of code in that side. After that, you can still edit the middle "Result".