Files
txarli.dev/src/posts/sort-git-branch.md
tina-cloud-app[bot] bd3a7ff41c TinaCMS content update
Co-authored-by: @cassidoo <1454517+cassidoo@users.noreply.github.com>
2024-02-15 16:02:12 +00:00

1.0 KiB

layout, title, slug, description, tags, added
layout title slug description tags added
../layouts/BlogPost.astro Sorting Git branches sort-git-branch If you're tired of your git branches being alphabetically sorted, you can change that!
technical
2024-02-15T15:46:32.808Z

Normally when you run git branch on a repository, you get your list of branches in alphabetical order, which can be very annoying if you have a lot of them (unless you have a very rigid naming system by ticket number or something).

You can change that now!

In your repo, if you do:

git branch --sort=-committerdate

This will sort all of your branches by the date of their last commit!

You can sort by:

  • authordate
  • committerdate
  • creatordate
  • objectsize
  • taggerdate

Plus, you can also do this globally if you want to always do it by one of these, like so:

git config --global branch.sort -committerdate

Or, you could set an alias:

git config --global alias.brcd "branch --sort=-committerdate"

Now go on and git committing!