With git revert 796a330
, 796a330 2
won't disappear from the log. Instead, another commit is created, which tries to apply the reversed patch of 796a330 2
onto 49740e5 3
.
As to the conflicts, here's an example. Suppose that in 539a76 1
C
is empty. Then in 796a330 2
, a line hello\n
is added. And then in 49740e5 3
, the line is replaced with world\n
.
The patch of 796a330 2
is from nothing to hello\n
and the patch of 49740e5 3
is from hello\n
to world\n
. The reversed patch of 796a330 2
is from hello\n
to nothing. When the reversed patch is to be applied onto 49740e5 3
, it can't find hello\n
in C
as C
only has world\n
. So it reports the conflicts.
In other words, the changes of 49740e5 3
are dependent on 796a330 2
's changes. If you want to revert 796a330 2
's changes without conflicts, you need to revert 49740e5 3
first. If the two sets of changes are independent, git revert 796a330
won't cause conflicts in this case.
Conflicts are not errors. You can just solve them by preserving the codes you want and removing the codes you don't. The conflicting marks should always be removed.