How to find the previous merge

How can I find the previous merge join between two branches?

I would like to see changes in my main branch since the last merge of the release cells into the main branch. To see changes in release branches from the last branch, it is as simple as git diff ...release

But obviously git diff release... doesn't work, because it also includes all changes until the last merge. So I think I need the commit identifier of the last merge to pass it to git diff

 git log --reverse --ancestry-path `git merge-base HEAD release`.. \ --format=format:%H|head -n1 

seems to work and can be used with git diff $(...) , but it seems terribly complicated. Is there an easier solution?

Example

  I / \ A1 B1 \ | | M | | A2 B2 

Here I is the initial commit. A[12] is the fixation of the issue, and B[12] is the main fixation. M is the previous commit. In this example, the changes between the last merge and the master are just the changes made to B2. git merge-base A2 B2 returns A 1. And git diff B2 A1 includes B1 changes. So the question is how to find M in the generally more complicated case so that you can run git diff M B2 without having to manually find M

+8
git
source share
2 answers

It seems that what you are looking for is the moment when the two branches begin to differ, and not the last merge between the two branches. The two concepts are different because your release branch may have been quickly redirected some time after it merged.

git merge-base master release will find the most recent common ancestor of your masters and releases (i.e. the last commit that has two things in common).

Then on the main you can use git diff [common ancestor] HEAD to see the changes that were made for mastering from a common ancestor.

+6
source share

This will show the last merge merge between the foo branch and the master

 git log foo master --oneline --date-order --merges -1 --oneline is just to keep the output short --date-order to get the latest first --merges to only show merge commits -1 to display the first result only 
-one
source share

All Articles