Deleting merged Git branches from your local machine Jul 26, 2022 This line of PowerShell will delete local Git branches which have already been merged to main: git branch --merged main | %{ $_.TrimStart() } | sls -NotMatch -Pattern '^(\* )?main$' | % { git branch -d $_ }