From bd3a7ff41ccb0998da6c398973ba69d8b1770017 Mon Sep 17 00:00:00 2001 From: "tina-cloud-app[bot]" <58178390+tina-cloud-app[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:02:12 +0000 Subject: [PATCH] TinaCMS content update Co-authored-by: @cassidoo <1454517+cassidoo@users.noreply.github.com> --- src/posts/sort-git-branch.md | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/posts/sort-git-branch.md diff --git a/src/posts/sort-git-branch.md b/src/posts/sort-git-branch.md new file mode 100644 index 0000000..7fb2770 --- /dev/null +++ b/src/posts/sort-git-branch.md @@ -0,0 +1,45 @@ +--- +layout: ../layouts/BlogPost.astro +title: Sorting Git branches +slug: sort-git-branch +description: >- + If you're tired of your git branches being alphabetically sorted, you can + change that! +tags: + - technical +added: 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: + +```shell +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: + +```shell +git config --global branch.sort -committerdate +``` + +Or, you could set an alias: + +```shell +git config --global alias.brcd "branch --sort=-committerdate" +``` + +Now go on and git committing!