How to list branches that contain a given commit?

前端 未结 3 1742
闹比i
闹比i 2020-11-22 02:23

How can I query git to find out which branches contain a given commit? gitk will usually list the branches, unless there are too many, in which case it just say

3条回答
  •  遥遥无期
    2020-11-22 03:06

    You may run:

    git log ..HEAD --ancestry-path --merges
    

    From comment of last commit in the output you may find original branch name

    Example:

           c---e---g--- feature
          /         \
    -a---b---d---f---h---j--- master
    
    git log e..master --ancestry-path --merges
    
    commit h
    Merge: g f
    Author: Eugen Konkov <>
    Date:   Sat Oct 1 00:54:18 2016 +0300
    
        Merge branch 'feature' into master
    

提交回复
热议问题