1

We have committed a change for one file using alm merge request. After one month we have noticed our change is missing.

We tried seeing logs for that file but we don't see our change there as well.

But when we see the logs of commit id 2e02e42d6b5094809295d375150d13238318968d. We can see that our changes got merged properly. Git logs of commit id

 git log 2e02e42d6b5094809295d375150d13238318968d
commit 2e02e42d6b5094809295d375150d13238318968d
Merge: 9e108526c5 c75d3cc631
Author: Sreekumar Menon <sreekumar.menon@oracle.com>
Date:   Wed Feb 19 11:19:43 2020 -0800

    Merge-Request: 12615 from 'users/amit.tiwary/enh30472668' into 'develop'

Git logs of file

 git log -p PrePostScripts.xml
commit 1870c07e6b0af5b63f92001f546a58488ee42979
Author: joshua.kesselman <joshua.kesselman@oracle.com>
Date:   Tue Apr 2 13:04:22 2019 -0700

Kindly let me know how to check what happened to the commit 2e02e42d6b5094809295d375150d13238318968d.

Paul
  • 317
  • 4
  • 15

2 Answers2

0

Note this in the merge commit:

Merge: 9e108526c5 c75d3cc631

9e108526c5 was the HEAD of the develop branch when the merge happened, and c75d3cc631 was the HEAD of the branch that got merged. Start investigating there by doing:

git checkout c75d3cc631

and investigating the state of the repository. The correct change should exist there. You should now start a bisect to see which commit removed the changes. To start the bisect do:

git bisect start

Since you're currently in c75d3cc631 and the change is there, mark it as good with:

git bisect good

Then switch back to HEAD and mark it as bad since the change is missing there:

git checkout develop
git bisect bad

Git will now automatically checkout a commit in the middle. See if the change is there. If not, do git bisect bad and git will continue. Once git checks out a commit where the change does exist, do git bisect good. Continue this process until git tells you that it found out which commit was responsible for the problem.

Nikos C.
  • 50,738
  • 9
  • 71
  • 96
  • Hi Nikos - In this case why are the changes done to file "PrePostScripts.xml" are missing. How it identify the person who overwritten the changes – Paul Mar 26 '20 at 09:07
  • @Paul Does `git show 1870c07` display the correct change? – Nikos C. Mar 26 '20 at 09:14
  • git show 1870c07 commit 1870c07e6b0af5b63f92001f546a58488ee42979 Author: joshua.kesselman Date: Tue Apr 2 13:04:22 2019 -0700 BUGID: 29280520 DESCRIPTION: Callback for delete enitities FIX: REVIEWER: IMPACTED AREA(s): TEST CASE(s): – Paul Mar 26 '20 at 09:19
  • My question is what happened to the commit 2e02e42d6b5094809295d375150d13238318968d finally – Paul Mar 26 '20 at 09:20
  • @Paul What do you mean what happened to it? It's there according to what you posted, and it's just a merge commit. `git show 2e02e42` shouldn't show any changes. Does it? – Nikos C. Mar 26 '20 at 09:21
  • It is giving the below output. But my file doesn't contain the changes now which I have noticed after a month. ```git show 2e02e42 commit 2e02e42d6b5094809295d375150d13238318968d Merge: 9e108526c5 c75d3cc631 Author: Sreekumar Menon Date: Wed Feb 19 11:19:43 2020 -0800 Merge-Request: 12615 from 'users/amit.tiwary/enh30472668' into 'develop' ``` – Paul Mar 26 '20 at 09:26
  • I have used command ``` git log --follow -- PrePostScripts.xml``` that gave me the output ```commit c75d3cc631ff66dd4f7f4b8223d67676b5c543c2 (origin/users/amit.tiwary/enh30472668) Author: Debadutta Rath Date: Tue Feb 18 23:53:27 2020 -0700 EPMPBCS-16347 Removing TRCS related entries from PrePostScripts.xml of Platform as Enh 30534998 - PROVIDE TRCS SPECIFIC PREANDPO commit 1870c07e6b0af5b63f92001f546a58488ee42979 Author: joshua.kesselman Date: Tue Apr 2 13:04:22 2019 -0700 ``` but the latest change is not existing. – Paul Mar 26 '20 at 09:32
  • @Paul Since the merge commit says `Merge: 9e108526c5 c75d3cc631`, I would look up what those commits are. `9e108526c5` was the HEAD in `develop` when the merge happened, and `c75d3cc631` was the HEAD in the branch that was merged. So start investigating `git show c75d3cc631`. – Nikos C. Mar 26 '20 at 09:39
  • @Paul You can also `git checkout c75d3cc631` and see what the state of the repo was at that point. (A `git checkout develop` will then bring you back out again from this detached state.) – Nikos C. Mar 26 '20 at 09:42
  • My changes looks good at c75d3cc631 but not sure which commit id or merge id overwritten my changes. I am trying to find that – Paul Mar 26 '20 at 09:45
  • @Paul You can now do a git bisect to find out which commit removed the changes. I completely changed my answer with instructions. – Nikos C. Mar 26 '20 at 09:56
0

In my case one feature branch got merged with develop and over written the changes I have made

Paul
  • 317
  • 4
  • 15