How to find the nearest parent of a Git branch?

后端 未结 21 1616
野性不改
野性不改 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:20

    This working fine for me.

    git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
    

    Courtesy answers from: @droidbot and @Jistanidiot

提交回复
热议问题