How to find the nearest parent of a Git branch?

后端 未结 21 1671
野性不改
野性不改 2020-11-22 00:54

Let\'s say I have the following local repository with a commit tree like this:

master --> a
            \\
             \\
      develop c --> d
               


        
21条回答
  •  时光取名叫无心
    2020-11-22 01:01

    Remember that, as described in "Git: Finding what branch a commit came from", you cannot easily pinpoint the branch where that commit has been made (branches can be renamed, moved, deleted...), even though git branch --contains is a start.

    • You can go back from commit to commit until git branch --contains doesn't list the feature branch and list develop branch,
    • compare that commit SHA1 to /refs/heads/develop

    If the two commits id match, you are good to go (that would mean the feature branch has its origin at the HEAD of develop).

提交回复
热议问题