{"thread":{"id":"65137","subject":"Feature request: support listing worktrees sorted by creation time","startedAt":"2026-03-05T07:14:54Z","lastAt":"2026-03-06T13:02:19Z","messageCount":6,"participants":["Norbert Kiesel","Johannes Sixt","Junio C Hamano","Erik Cervin Edin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"537904","messageId":"CAM+g_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa=Et-gw@mail.gmail.com","threadId":"65137","inReplyTo":null,"subject":"Feature request: support listing worktrees sorted by creation time","fromName":"Norbert Kiesel","fromEmail":"nkiesel@gmail.com","sentAt":"2026-03-05T07:14:41Z","receivedAt":"2026-03-05T07:14:54Z","isPatch":false,"sender":{"key":"nkiesel@gmail.com","avatar":null},"body":"Hi!\n\nI have multiple repos with more than 20 worktrees, and sometimes\nforget the name of a recently added worktree. Therefore it would\nreally be nice if I could use something like ‘git worktree list\n—created’ to list them by their creation timestamp. Is that something\nthat makes sense to you as well? I could also create a pull request\nfor this if you would like it.\n\nBest,\n  Norbert\n"},{"id":"537905","messageId":"264862d1-0f83-4d0b-be11-d8e479c7d8da@kdbg.org","threadId":"65137","inReplyTo":"CAM+g_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa=Et-gw@mail.gmail.com","subject":"Re: Feature request: support listing worktrees sorted by creation time","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-03-05T07:35:38Z","receivedAt":"2026-03-05T07:35:42Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 05.03.26 um 08:14 schrieb Norbert Kiesel:\n> I have multiple repos with more than 20 worktrees, and sometimes\n> forget the name of a recently added worktree. Therefore it would\n> really be nice if I could use something like ‘git worktree list\n> —created’ to list them by their creation timestamp. Is that something\n> that makes sense to you as well? I could also create a pull request\n> for this if you would like it.\nI don't think this is warranted as a feature for a special-purpose\nuse-case. Assuming you don't have spaces in your worktree directory names,\n\n  git worktree list | cut -d' ' -f1 | xargs ls -ldtr\n\nlists the worktree directories by modification time. The last is the one\nthat was modified most recently. That should help your memory.\n\n-- Hannes\n\n"},{"id":"537907","messageId":"CAM+g_Nsw52JysCsv-FVznh-RAPxYm0kA=Kj2o+KVB5uZpGA0qg@mail.gmail.com","threadId":"65137","inReplyTo":"264862d1-0f83-4d0b-be11-d8e479c7d8da@kdbg.org","subject":"Re: Feature request: support listing worktrees sorted by creation time","fromName":"Norbert Kiesel","fromEmail":"nkiesel@gmail.com","sentAt":"2026-03-05T07:41:06Z","receivedAt":"2026-03-05T07:41:19Z","isPatch":false,"sender":{"key":"nkiesel@gmail.com","avatar":null},"body":"My understanding is that the timestamp of the base worktree\ndirectories is updated whenever a new file is created in that\ndirectory, and thus this will not preserve the worktree creation time.\nTherefore, I would like to have an explicit creation timestamp in the\nworktree metadata.\n\n\nOn Wed, Mar 4, 2026 at 11:35 PM Johannes Sixt <j6t@kdbg.org> wrote:\n>\n> Am 05.03.26 um 08:14 schrieb Norbert Kiesel:\n> > I have multiple repos with more than 20 worktrees, and sometimes\n> > forget the name of a recently added worktree. Therefore it would\n> > really be nice if I could use something like ‘git worktree list\n> > —created’ to list them by their creation timestamp. Is that something\n> > that makes sense to you as well? I could also create a pull request\n> > for this if you would like it.\n> I don't think this is warranted as a feature for a special-purpose\n> use-case. Assuming you don't have spaces in your worktree directory names,\n>\n>   git worktree list | cut -d' ' -f1 | xargs ls -ldtr\n>\n> lists the worktree directories by modification time. The last is the one\n> that was modified most recently. That should help your memory.\n>\n> -- Hannes\n>\n"},{"id":"537979","messageId":"xmqqqzpy46n5.fsf@gitster.g","threadId":"65137","inReplyTo":"CAM+g_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa=Et-gw@mail.gmail.com","subject":"Re: Feature request: support listing worktrees sorted by creation time","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-05T15:50:54Z","receivedAt":"2026-03-05T15:50:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Norbert Kiesel <nkiesel@gmail.com> writes:\n\n> I have multiple repos with more than 20 worktrees, and sometimes\n> forget the name of a recently added worktree. Therefore it would\n> really be nice if I could use something like ‘git worktree list\n> —created’ to list them by their creation timestamp. Is that something\n> that makes sense to you as well? I could also create a pull request\n> for this if you would like it.\n\nI do not think we have any _record_ of when each of these worktrees\nwas created, so this is not a realistic request.\n\nThe output from \"git worktree list\" may be more than 20 lines, but\nisn't your terminal taller than 20 lines ;-)?\n\nSince very early days of Git, we have created .git/description file\nthat is not used very much (I think it is shown in gitweb).  Perhaps\nworktree should have an equivalent in per-worktree part of their\n.git/ directory and \"git worktree list --verbose\" can use its\ncontents in addition to the additional pieces information it already\nshows, or something like that, perhaps?\n"},{"id":"538032","messageId":"CAM+g_NsX5jdjbhtLznxJ=ZRtJ4ShEAzTHzkjgnidyDr-a2r=kw@mail.gmail.com","threadId":"65137","inReplyTo":"xmqqqzpy46n5.fsf@gitster.g","subject":"Re: Feature request: support listing worktrees sorted by creation time","fromName":"Norbert Kiesel","fromEmail":"nkiesel@gmail.com","sentAt":"2026-03-05T23:36:55Z","receivedAt":"2026-03-05T23:37:09Z","isPatch":false,"sender":{"key":"nkiesel@gmail.com","avatar":null},"body":"Wrote a Zsh script that uses the \"directory create time\" but when a\nworktree is moved then that will be updated. So would still like to\nhave `git worktree add` store the current timestamp somewhere.\n\n```zsh\n#!/bin/zsh\n# List git worktrees with creation timestamps, sorted oldest to newest\n\nwt_path=\"\" branch=\"\"\ntypeset -a ts_arr wt_arr br_arr\n\nflush() {\n    [[ -z $wt_path ]] && return\n    local epoch=$(stat -f '%B' \"$wt_path\" 2>/dev/null)\n    ts_arr+=(\"${epoch:-0}\")\n    wt_arr+=(\"$wt_path\")\n    br_arr+=(\"${branch:-(detached)}\")\n    wt_path=\"\" branch=\"\"\n}\n\nwhile IFS= read -r line; do\n    case $line in\n        worktree\\ *)  flush; wt_path=${line#worktree } ;;\n        branch\\ *)    branch=${line#branch refs/heads/} ;;\n        detached)     branch=\"(detached)\" ;;\n        \"\")           flush ;;\n    esac\ndone < <(git worktree list --porcelain)\nflush\n\n# Find max branch width for column alignment\ninteger max_br=0\nfor br in \"${br_arr[@]}\"; do\n    (( ${#br} > max_br )) && max_br=${#br}\ndone\n\n# Print first entry (main worktree) always first\nprintf \"%s  %-${max_br}s  %s\\n\" \"$(date -r \"${ts_arr[1]}\"\n+\"%Y-%m-%d\")\" \"${br_arr[1]}\" \"${wt_arr[1]}\"\n\n# Collect remaining entries prefixed with epoch for numeric sort\ntypeset -a rest_lines\nfor (( i=2; i<=${#ts_arr}; i++ )); do\n    rest_lines+=(\"${ts_arr[$i]}  $(printf \"%-${max_br}s  %s\"\n\"${br_arr[$i]}\" \"${wt_arr[$i]}\")\")\ndone\n\n# Sort numerically by epoch, then replace epoch with formatted date\n(( ${#rest_lines} > 0 )) && print -l \"${(on)rest_lines[@]}\" | while\nIFS= read -r line; do\n    epoch=${line%% *}\n    printf \"%s  %s\\n\" \"$(date -r \"$epoch\" +\"%Y-%m-%d\")\" \"${line#*  }\"\ndone\n```\n\nOn Thu, Mar 5, 2026 at 7:50 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Norbert Kiesel <nkiesel@gmail.com> writes:\n>\n> > I have multiple repos with more than 20 worktrees, and sometimes\n> > forget the name of a recently added worktree. Therefore it would\n> > really be nice if I could use something like ‘git worktree list\n> > —created’ to list them by their creation timestamp. Is that something\n> > that makes sense to you as well? I could also create a pull request\n> > for this if you would like it.\n>\n> I do not think we have any _record_ of when each of these worktrees\n> was created, so this is not a realistic request.\n>\n> The output from \"git worktree list\" may be more than 20 lines, but\n> isn't your terminal taller than 20 lines ;-)?\n>\n> Since very early days of Git, we have created .git/description file\n> that is not used very much (I think it is shown in gitweb).  Perhaps\n> worktree should have an equivalent in per-worktree part of their\n> .git/ directory and \"git worktree list --verbose\" can use its\n> contents in addition to the additional pieces information it already\n> shows, or something like that, perhaps?\n"},{"id":"538072","messageId":"aarKxwOiv0XmoS6c@Eriks-MacBook-Pro.local","threadId":"65137","inReplyTo":"xmqqqzpy46n5.fsf@gitster.g","subject":"Re: Feature request: support listing worktrees sorted by creation time","fromName":"Erik Cervin Edin","fromEmail":"erik@cervined.in","sentAt":"2026-03-06T13:02:15Z","receivedAt":"2026-03-06T13:02:19Z","isPatch":false,"sender":{"key":"erik@cervined.in","avatar":null},"body":"On 26/03/05 07:50AM, Junio C Hamano wrote:\n> \n> Since very early days of Git, we have created .git/description file\n> that is not used very much (I think it is shown in gitweb).  Perhaps\n> worktree should have an equivalent in per-worktree part of their\n> .git/ directory and \"git worktree list --verbose\" can use its\n> contents in addition to the additional pieces information it already\n> shows, or something like that, perhaps?\n> \n\nI think that sounds like a nice addition. I frequently name the worktree\nto encode the intent of the worktree, but that can be a bit clunky.\nHaving a way to describe it and/or metadata sounds nice!\n"}]}