Check parent of a commit merge commit
git show --pretty=raw 3706454
Merge Commit
Reference: https://blog.experteer.engineering/what-are-parents-on-git-merge-commits.html
A Merge commit, unlike other commit have two parents. Take the following example:
Hình dưới
Branch B is checked out from A2 and later merged into Branch A with a merge commit M1. In this case, M1 has two parents.
Parent 1: A5 (Commit changed File1)
Parent 2: B3 (Commit changed File2)
If one is to revert the changes that were applied on Branch A because of the merge M1, they want the mainline as A5, so parent 1
$ git revert M1 -m 1
What GIT does is that is reverts the diff between M1 and A5, which are changes to File2. After the revert, Branch A will have only changes to File1.
Revert merge commit
Reference: https://repository.prace-ri.eu/git/help/user/project/merge_requests/revert_changes.md
When you revert a merge commit, the branch you merged to (usually main) is always the first parent. To revert a merge commit to a different parent, you must revert the commit from the command line:
https://blog.experteer.engineering/what-are-parents-on-git-merge-commits.html
Identify the SHA of the parent commit you want to revert to.
Identify the parent number of the commit you want to revert to. (Defaults to 1, for the first parent.)
Modify this command, replacing 2 with the parent number, and 7a39eb0 with the commit SHA:
git revert -m 2 7a39eb0
update