Skip to main content

Delete local Git branches with Nushell

If you accumulate a lot of local Git branches over time, you can get rid of them in one go with the following Nushell script:

nu
(git branch | lines | where ($it !~ '^\*') | each {|br| git branch -D ($br | str trim)} | str trim)