Getting the merge branch name of a merge commit

Git is such a well written piece of software, that you can spend a long time using it without really understanding whats going on.

I'm trying to get the name of the branch which was merged with the master branch most recently, and I don't seem to be getting anywhere with git log, git show etc.

Github has the branch name history when I look at the commits to master, but I'm wondering if this is something that github is keeping track of additionally and not something I can access by git. Any help would be much appreciated!


Solution 1:

As commented, this information is not recorded.

You might consider a post-merge hook, like this one, which would:

  • get the branch that was just merged (through git reflog)
  • use git notes add in order to add the the current merge commit the information you want.
    That way, no need to modify the description/merge commit message.

That is a local hook though, that would need to be installed on every cloned repository. If you are alone working on the repository, that would work.