Is it possible to configure magit to sort branches inserted with magit-insert-local-branches into the main status page according to some criteria, for example whatever is configured as branch.sort in the git configuration?

1 Answer 1


This does not seem to be possible out of the box with version 20220919. The function which reads the branches is magit-refs--format-local-branches in magit-refs.el. It calls magit-git-lines to run git for-each-ref with suitable parameters to get the branch names. The variable magit-buffer-arguments is passed as an argument too, but this variable is not settable (and would not make sense to be settable) for the status page.

As explained in the comments to https://stackoverflow.com/q/73800506/2954288, using git config for-each-ref.sort -committerdate can not work, since for-each-ref does not care about configuration options.

Patching magit sensibly seems difficult, since there is just no concept to pass configured parameters to magit-refs--format-local-branches.

Hacking it by inserting "--sort=-committerdate" in the right place does work, but may have side effects I did not experience and will be overwritten with the next update.

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.