Recently at work, we lost some code on a project under version control using git (and a private github repository).
I used git bisect
to find the culprit commit, and I got really surprised discovering it was looking like a revert commit, but also had two parents like merge commits :
commit b5f97311eea2905baf8a96fddec22321d952f05c
Merge: 8cc7371 131d463
Author: Bob <[email protected]>
Date: Fri May 22 19:42:25 2015 +0200
Revert "ISB-CPW-3627 - Mise en place du calage des filtres DS1/DS2/DS3/DS4"
This reverts commit 8cc7371e7133b68db95ac8e9aeb730d7889a1166.
This issue has been resolved by creating a new branch from an ancestor commit, and applying some patches on top of that new branch.
So I don't need help to fix that, I just want to understand how can a revert commit could also be a merge commit, what happened, and how to reproduce this weird behavior.
I tried to reproduce it like this :
- create a new branch at
8cc7371
- git revert
8cc7371
It creates a revert commit with a single parent (8cc7371
) as expected.
The culprit commit author uses Atlassian SourceTree instead of the native command line interface, so I also tried using the revert feature within SourceTree and got the same result as above (single parent).
After running some git commands on b5f9731
, I noticed that git diff
and git show
are not reporting the same file set :
$ git diff b5f9731..8cc7371 --name-only
=> 2 files :
application/sites/frontend/views/scripts/Layout/Foobar/PointsDeVente/index.tpl
public/media/design/frontend/css/main-dev.css
$ git show --oneline --name-only b5f9731
=> 1 file :
public/media/design/frontend/css/main-dev.css
SourceTree and Github are showing 2 files.
You can find how the graph looks like here : graph.html, and some git commands results there : misc.html.
Could anybody explain what happened with b5f9731
?
What comes to my mind:
Message is taken from
abcdef
.This all results in the new
b5f9731
. It has two parents from a merge commit and the message from the revert commit.