I just learned about magit-remote-prune for cleaning up stale remote branch.

For merged local branches, I often use git branch | git branch -d to clean up. Is there a way to do that in Magit; conveniently listing merged local branches, and selecting them for deletion?

1 Answer 1


git branch lists all local branches as well as *, so the command you have given cannot actually be used to delete all merged branches and nothing else. Or if actually does do it while printing some error messages in the process, then I would never-the-less strongly advice against doing that.

Magit does not have a "delete all merged branches" command.

You can however list all branches merged into master using C-u y - M o master RET (or C-u y - m if master is checked out). Then you can mark these branches using the region and delete them using k.

  • 2
    Nifty. Can you clarify what the keybinding sequence is when you're on master? C-u y - m, and then c?
    – Clément
    Mar 19, 2020 at 13:46
  • I'm not getting this to work. The error message I'm getting is that y - is undefined.
    – Frost
    May 6, 2021 at 8:31
  • 1
    y is supposed to be bound to magit-show-refs but if you use e.g. evil, then the binding might be different.
    – tarsius
    May 6, 2021 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.