git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature request: highlight local worktree in `worktree list`

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 20, 2024, 14:38 UTC
Message-ID
<xmqqedc5hsse.fsf@gitster.g>
In-Reply-To
<20240320100232.GB2446185@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I'm not sure if this is a dumb idea or not, but: what if git-branch
> learned to display branches associated with worktrees (just like "-r"
> lists remote branches, etc).

A branch usually, but not necessarily, is checked out in at most one worktree, so the display may become a bit more cluttered when more than one checks out the same branch, but it is similar to how a commit pointed at by multiple refs are shown with --decorate, so I do not think it is such a huge deal.

> I think the only thing it wouldn't do is show worktrees that are
> detached from any branch at all. I'm not sure if that's important to
> your workflow or not.

If such a mode in "git branch --list" were written, I would imagine that the output from such a mode will include detached HEAD from other worktrees as well. Perhaps something like this?

    $ git branch --list --worktrees
      (HEAD detached from ffa877cd2f, checked out in worktree 'buildtest')
      jch (checked out in worktree 'integration')
      maint
    * master (checked out in the primary worktree)
      next
      seen
      jk/branch-list-with-worktree
Previous: Jeff KingNext: Jeff King
Message 3 of 7 in “Feature request: highlight local worktree in `worktree list`”
  1. Matt HickfordMar 20, 2024
  2. Jeff KingMar 20, 2024
  3. Junio C HamanoMar 20, 2024
  4. Jeff KingMar 20, 2024
  5. Matt HickfordMar 21, 2024
  6. Rubén JustoMar 20, 2024
  7. Chris TorekMar 21, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.