Search code examples
gitgit-merge

Under which circumstances does git silently skip a commit during a merge


Please see the image below while reading.

Branch B (source branch) is regularly merged in to Branch A (target branch). Generally when a merge happens all changes that were made since the last time merge end up in Branch A (target branch). I encountered a situation where that's not the case:

Branch B (source branch) had two new commits. I merged into branch A (target branch). Only the change of one of the commits ended up in branch A (target branch) - Only changes of commit X2 were merged; changes of commit X1 were not. It's very important to note, that the logs and history say that both commits were actually merged - as shown in the graph below. The final commit Y1 in branch A says that its parent is X1 of branch B and Y2 from branch A.

enter image description here


Solution

  • Under no circumstances.

    Using the labels in your supplied graph, do git diff Y1^1...Y1^2 and git diff Y1^2...Y1^1. Those are the diffs Git merged to produce Y1, your problematic resulting merge commit. See here for an older take on this, unless there's something else going on here that's likely to be a dup of your question.