Reputation: 499
I have my master branch and a dev branch that I periodically merge to master:
dev --A---B---C---D---E---F---G--
/ \ \
master ----------M1------M2----------
M1 and M2 are merge commits.
How can I find the SHA of the last commit on dev that has been merged into master? In this example, I want the SHA of commit D.
Upvotes: 3
Views: 820
Reputation: 60547
If you never merge to the dev branch you're golden with the git merge-base
. If you're merging from master as well, you have to check master's first-parent history for the most recent merge commit whose second parent is in dev's first-parent history.
Brute force:
awk ' ARGIND==1 { tomaster[$NF]=1; next }
$1 in tomaster { print; exit }
' <(git rev-list --first-parent --merges --parents master) \
<(git rev-list --first-parent dev)
Upvotes: 2
Reputation: 52151
That would be the most recent common ancestor, or merge base :
git merge-base master dev
Upvotes: 4