Find all merge events between two branches

420 Views Asked by At

I'm trying to determine the frequency with which master is merged into a specific release branch. So, I want to know the history of all merge-bases. Is there a way to list all of the merges that have happened between two branches?

1

There are 1 best solutions below

10
LeGEC On

You can tell git log to output the commit hashes of the parent commits for each displayed commit :

git log --format="%p" --first-parent --merges release

# to get only second parents, just use awk or cut :
git log --format="%p" --first-parent --merges release | awk '{ print $2 }'

You can now check one by one whether each commit is part of branch master, perhaps using :

git rev-list --first-parent master | grep $sha

("the first parents of a branch" is the closest thing you will get to a history of that branch)


using a one liner :

git rev-list --format="%P" --first-parent --merges release | awk '{ print $2 }' |\
    grep -F -f <(git rev-list --first-parent master)

or adapting your usage of "uniq" in your comments:

(git rev-list --format="%P" --first-parent --merges release | awk '{ print $2 }';\
  git rev-list --first-parent master) | sort | uniq -d