git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: lilinchao@oschina.cn
Cc: git <git@vger.kernel.org>
Subject: Re: [Question] How to know which branch(ref) is the latest updated branch?
Date: Thu, 18 Aug 2022 10:08:19 -0700	[thread overview]
Message-ID: <xmqqa681qy2k.fsf@gitster.g> (raw)
In-Reply-To: <2022081818034939145210@oschina.cn> (lilinchao@oschina.cn's message of "Thu, 18 Aug 2022 18:04:49 +0800")

"lilinchao@oschina.cn" <lilinchao@oschina.cn> writes:

> In a git based workflow, there are usually many active branches.
> So, is there a convenient way to quickly know which branch is the
> latest updated?

These days "git branch" has "--sort" option, inherited from "for-each-ref",
so

    git branch --sort=-committerdate

lists them from the most-recently-committed [*].

HOWEVER.

There is no way to sort on the time when each branch was last
updated.  You may do

    git branch newbranch HEAD@{2.years.ago}

to create a new branch (i.e. it is the last updated branch) that
points at a commit that existed 2 years ago (hence it would be at
least 2 years old, possibly more).  If for-each-ref learns a new
placeholder %(reflogtime) that can be used to represent the
timestamp of the latest reflog entry, you should be able to sort by
the time when branch was last updated, but not until then.


[Footnote]

I have this handy alias

    [alias]
    notyet = branch --no-merged jch --no-merged seen --sort=-committerdate '??/*'

to remind me of topics that are not yet in my integration branches
while rebuilding them.

In the end result, 'seen' is supposed to include "everything I saw
and found possibly interesting", and 'jch' is supposed to be a
subset of it, but explicitly saying "show branches that are not in
either of these two" helps while rebuilding them (and I do so a few
times a day).

      parent reply	other threads:[~2022-08-18 17:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 10:04 [Question] How to know which branch(ref) is the latest updated branch? lilinchao
2022-08-18 14:30 ` Dan Pristupov
2022-08-18 17:08 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa681qy2k.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=lilinchao@oschina.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).