I'm trying to get the first merge commit for a given SHA. I tried the script from here: https://stackoverflow.com/a/30998048 (has a command for git find-merge
) but unfortunately it doesn't do quite what I need.
The situation that I have is that I had a fix
branch off of a release
branch that was then merged into the release
branch. From there the release
branch was merged into main
. So my tree looked like this:
main - - - - - - - - - - - - -
/ (merge #2)
release - - - - - - - - - - /
\ / (merge #1)
fix - - - - /
However using the git find-merge (fix SHA) (merge #2 SHA)
with the fix branch SHA gives the SHA of merge #2 instead of merge #1. I want to know the SHA of the first time a commit was merged. Does anyone have any git
terminal command to do so?
A note that if I use git find-merge (fix SHA) (merge #2 SHA - 1)
and give it the SHA of the fix commit and the SHA 1 before merge #2
it works, however if there was a merge #3 in there I think that is the SHA I would get back instead.