Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6119165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:31:12+00:00 2026-05-23T15:31:12+00:00

When I type git branch , I receive a list of branches that appear

  • 0

When I type git branch, I receive a list of branches that appear to be sorted alphabetically instead of being sorted by their creation time.

Is there a way to make the output of git branch sorted by date?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:31:13+00:00Added an answer on May 23, 2026 at 3:31 pm

    Edit: Since Git version 2.19 (late 2018), Git obeys a branch.sort configuration. Since Git version 2.7.0 (early 2016), git branch itself allows sorting, so that you do not have to use git for-each-ref directly.

    Edit

    Alas there are apparent problems with the sorting options taken by git-for-each-ref. Since that command is (obviously) explicitely aimed at showing refs and accepts the --sort option, I’m thinking of this as a likely bug[1].

    Here is the best options I can further come up with, but the output is quite far estranged from the original format (because they rely on decorating revisions after the fact to refer to branches). Ah well, maybe it is of use for you:


    [1] if this were git-rev-list or git-log I would think the problem would be that we’re not actually walking a revision tree; we’re actively trying to show only tips of trees, without walking them.

    Temporary alternative

    git log --no-walk --date-order --oneline --decorate \
           $(git rev-list --branches --no-walk)
    

    This would give you a list similar to

    4934e92 (HEAD, origin/testing, origin/HEAD, testing) reviewed INSTALL file as per #1331
    6215be7 (origin/maint, maint) reviewed INSTALL file as per #1331
    1e5e121 (origin/emmanuel, emmanuel) buffers: adjust the size in zfsfuse_stat
    e96783e (origin/compress, compress) buffers: adjust the size in zfsfuse_stat
    f6e2c6c (origin/unstable, unstable) revert the fatal condition again
    dd52720 (origin/master-lucid, master-lucid) lucid
    3b32fa7 (tag: 0.7.0, origin/master, master) panic revocation of 0.7.0-0 package necessitates an update
    6eaa64f (origin/maint-0.6.9, maint-0.6.9) Replace remount by drop_caches (on rollback)
    

    _As you can see, the result can be a bit overwhelming in the presence of many remote (tracking) branches, which effectively alias the same revisions. However, the result is properly ordered by (descending) date.

    The correct (unfortunately broken?) approach…

    No, but you should be able to do

    git for-each-ref --sort='-*committerdate' --format="%(refname:short)" refs/heads/
    

    (use --sort='-*authordate' for author date ordering)

    On my test repo, this yields:

    compress
    emmanuel
    maint
    maint-0.6.9
    master
    master-lucid
    testing
    unstable
    

    Alias

    you can create a git alias to do this: append the following lines to .git/config

    [alias]
    branch2 = git for-each-ref --sort='-*committerdate' --format="%(refname:short)" refs/heads/
    

    From then on, you could just say git branch2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now, when I type git branch it lists my branches in an arbitrary
When I type 'git status' the output is # On branch master # Untracked
When I type git difftool under plain cygwin shell, I just receive benign exit:
I created a tracking branch so whowasout.com tracked whowasout.com/master $ git remote -v origin
I started on a simple task in the main branch. ya' know the type
Some Background I have been using Git for a while now. The projects that
I added the following line to .gitignore : sites/default/settings.php but when I type git
I installed git a long time ago on Snow Leopard... Recently, I downloaded and
These are from the spring amqp samples on github at https://github.com/SpringSource/spring-amqp-samples.git what type of
I've recently tried using branches in git but while they work allright whatever I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.