How to find the nearest parent of a Git branch?

后端 未结 21 1609
野性不改
野性不改 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 00:59

    Here is a PowerShell implementation of Mark Reed's solution:

    git show-branch -a | where-object { $_.Contains('*') -eq $true} | Where-object {$_.Contains($branchName) -ne $true } | select -first 1 | % {$_ -replace('.*\[(.*)\].*','$1')} | % { $_ -replace('[\^~].*','') }
    

提交回复
热议问题