Search code examples
gitgit-merge

git merge: Does it matter which commit is newer?


Suppose I have two commmits, A and B. Suppose I am merging B into A. Does it matter whether A or B is the more recent commit? Or will I get the same result independent of the timestamps?


Solution

  • will I get the same result independent of the timestamps?

    Yes. A merge is performed by enacting simultaneously the "changes" on both sides since the point where the sides diverged. Both sides weigh 100% equally. It doesn't matter how they relate temporally or which side is being merged into which.

    A common source of confusion, though, is failure to realize that lack of change on one side means no contribution. If the divergence point has Hey, and if one side now has Ho and the other side has Hey, the result of the merge will be Ho.