Show the original branch for a commit

后端 未结 9 2209
野的像风
野的像风 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 04:59

    A Git branch is nothing else than a "named pointer to a commit" (that's a fundamental different concept than in other well-known VCS).

    This situation is clear, commit A is on branch-1, commit B on branch-2:

      o A [branch-1]
      |
    o | B [branch-2]
    | |
    

    After merging is becomes unclear whether A (or B) originally was on branch-1 or branch-2:

    o [branch-1] [branch-2]
    |
    o merged 
    |\
    | o A
    | |
    o | B
    | |
    

    Maybe you can guess on what Git branch the commit A was if you have tagged parent commits of A, e.g. release-1 and you know that this tag only was given for commits in branch-1.

    o [branch-1] [branch-2]
    |
    o merged 
    |\
    | o A
    | |
    o | B
    | |
    | o 

提交回复
热议问题