Show the original branch for a commit

后端 未结 9 2210
野的像风
野的像风 2020-12-05 04:14

I\'ve used git-blame to find a particular commit. Now I want to find the branch that it originally came from. (From there, I\'ll use the branch name to find the particular t

9条回答
  •  伪装坚强ぢ
    2020-12-05 05:10

    I found a simpler way to do it: it's in the message of the last commit of git log ..HEAD --merges!

    This command shows the merges that have happened between master and the commit; the last commit output by this command is the first merge commit that included it. It usually contains the branch name, so even if the branch was deleted you can find its name.

    To get only the name of the branch just type git log ..HEAD --merges --oneline |tail -1

提交回复
热议问题