git fetch origin --prune doesn't delete local branches?

前端 未结 5 1293
夕颜
夕颜 2020-12-08 06:05

At one point I thought that git fetch origin --prune deleted local branches that were no longer present on the server. Somehow this is not my experience at the

5条回答
  •  一生所求
    2020-12-08 06:45

    This is how I do it with Powershell.

    PS> git branch --v | ? { $_ -match "\[gone\]" } | % { -split $_ | select -First 1 } | % { git branch -D $_ }
    

    You can then create an alias like:

    PS> Function func_gitprune { git branch --v | ? { $_ -match "\[gone\]" } | % { -split $_ | select -First 1 } | % { git branch -D $_ } }
    
    PS> Set-Alias -Name gitprune -Value func_gitprune
    

    and execute it every time you need by running

    PS> gitprune
    

提交回复
热议问题