-1

One of colleagues is constantly corrupting git (AWS CodeCommit). Visual commit graph is similar to:

+ ccc
|
+   xxx (merge commit of branch master)
|\
| + bbb
+ | aaa
| | 
+ | xx1
| + yy1
+ | zzz (merge commit of branch master)
|\|
| + yy2
+ | xx1

Commit xxx does not contain changes of commit bbb (lost changes). Merge commit is done by git pull due to local configuration pull.ff=no.
Commit xxx shows parent commits: aaa then bbb
Changed files of commit xxx does not show file changed in commit bbb. Commit xxx overwrites file changed in commit bbb.
According to graph, there was merge of commit bbb. I do not understand what happened. It looks like no merge is done??? But if not merged, why git allowed push?

Edit to answer your question
@knittl I want to know where are changes from bbb commit? ccc commit shows changes, not related to file changed in bbb commit. ccc commit shows content of file (changed in commit bbbb) as at time when commit aaa was done (no merge). My task is now to go thru history and see which changes are lost. (beside bbb commit, there were many more commits and those commits are in the same line as bbb commit. These changes are lost and overwritten by aaa commit then ccc commit. I am confused by parent commit of ccc. First parent is aaa, then bbb. It makes no sense since ccc commit does not contain changes of file in commit bbb

zdenko.s
  • 931
  • 1
  • 12
  • 29
  • You can do `git log -p` to see changes made in each commit. – rkochar Aug 08 '23 at 09:15
  • The other person might have done `git merge -s ours branch-b` (this will ignore any changes of bbb). As to _why_ they do that: no idea – knittl Aug 08 '23 at 09:21
  • @rkochar I checked AWS console and it does not show changes in commit ccc of file which is changed in commit bbb. ccc commit shows file content is same as aaa commit. I am confused about parent commit. Although bbb is shown as parent of parent, changes are not present in ccc commit. – zdenko.s Aug 08 '23 at 11:15
  • @knittl Guy uses VS Code and regular UI actions. I cannot check his history but pretty sure he did not do merge (cannot guaranty). – zdenko.s Aug 08 '23 at 11:17
  • @zdenko.s there is a merge commit, so he must have done a merge. Perhaps not explicitly, but as part of a `git pull` ("update/sync repo"; I don't know how VSCode names this action). If there were conflicts and he chose "use my version", that would also undo changes of the branch. What exactly is your question now; what do you want to know? – knittl Aug 08 '23 at 11:36
  • A merge has two sides. You cannot expect the merge commit to merely copy what `bbb` shows in the file; the contributions on _both_ sides since `yy2` are relevant. – matt Aug 08 '23 at 14:02
  • @matt not necessarily. A merge commit is not that different from a regular commit: it contains a single tree ref and a parent ref. The only difference is that a merge commit contains multiple parent refs (at least 2, but more are possible). The tree _could_ be any valid tree ref (but is usually constructed from the parent commits' trees) – knittl Aug 08 '23 at 14:12
  • @knittl A merge commit that is not an enactment of the diffs on both sides since the merge base is an evil merge. The OP _seems_ to be suggesting that this _is_ an evil merge. But first let us establish that fact; and in order to establish it, we need to make sure that the OP understand what to expect from a normal merge. – matt Aug 08 '23 at 16:35
  • @knittl "What exactly is your question now; what do you want to know" There is no merge conflict on particular file (let us call it a.txt). Developer did not touch file a.txt. Merge commit shows 3 affected files, none of them is file a.txt. Still, file a.txt has content of commit 'aaa', although another guy modified only file a.txt in commit 'bbb'. My question is: If no merge conflict, and developer did 'pull' in VS code, why merge commit has overwritten a.txt file from commit aaa and not used commit bbb? – zdenko.s Aug 09 '23 at 09:27
  • @zdenko.s has there been a "revert" commit? Changes that were reverted will not be merged again. But I really don't know what your colleague did; maybe they amended the merge commit? – knittl Aug 09 '23 at 11:11

0 Answers0