* Feature request: support listing worktrees sorted by creation time
@ 2026-03-05 7:14 Norbert Kiesel
2026-03-05 7:35 ` Johannes Sixt
2026-03-05 15:50 ` Junio C Hamano
0 siblings, 2 replies; 6+ messages in thread
From: Norbert Kiesel @ 2026-03-05 7:14 UTC (permalink / raw)
To: Git Mailing List
Hi!
I have multiple repos with more than 20 worktrees, and sometimes
forget the name of a recently added worktree. Therefore it would
really be nice if I could use something like ‘git worktree list
—created’ to list them by their creation timestamp. Is that something
that makes sense to you as well? I could also create a pull request
for this if you would like it.
Best,
Norbert
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Feature request: support listing worktrees sorted by creation time
2026-03-05 7:14 Feature request: support listing worktrees sorted by creation time Norbert Kiesel
@ 2026-03-05 7:35 ` Johannes Sixt
2026-03-05 7:41 ` Norbert Kiesel
2026-03-05 15:50 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2026-03-05 7:35 UTC (permalink / raw)
To: Norbert Kiesel; +Cc: Git Mailing List
Am 05.03.26 um 08:14 schrieb Norbert Kiesel:
> I have multiple repos with more than 20 worktrees, and sometimes
> forget the name of a recently added worktree. Therefore it would
> really be nice if I could use something like ‘git worktree list
> —created’ to list them by their creation timestamp. Is that something
> that makes sense to you as well? I could also create a pull request
> for this if you would like it.
I don't think this is warranted as a feature for a special-purpose
use-case. Assuming you don't have spaces in your worktree directory names,
git worktree list | cut -d' ' -f1 | xargs ls -ldtr
lists the worktree directories by modification time. The last is the one
that was modified most recently. That should help your memory.
-- Hannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Feature request: support listing worktrees sorted by creation time
2026-03-05 7:35 ` Johannes Sixt
@ 2026-03-05 7:41 ` Norbert Kiesel
0 siblings, 0 replies; 6+ messages in thread
From: Norbert Kiesel @ 2026-03-05 7:41 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Git Mailing List
My understanding is that the timestamp of the base worktree
directories is updated whenever a new file is created in that
directory, and thus this will not preserve the worktree creation time.
Therefore, I would like to have an explicit creation timestamp in the
worktree metadata.
On Wed, Mar 4, 2026 at 11:35 PM Johannes Sixt <j6t@kdbg.org> wrote:
>
> Am 05.03.26 um 08:14 schrieb Norbert Kiesel:
> > I have multiple repos with more than 20 worktrees, and sometimes
> > forget the name of a recently added worktree. Therefore it would
> > really be nice if I could use something like ‘git worktree list
> > —created’ to list them by their creation timestamp. Is that something
> > that makes sense to you as well? I could also create a pull request
> > for this if you would like it.
> I don't think this is warranted as a feature for a special-purpose
> use-case. Assuming you don't have spaces in your worktree directory names,
>
> git worktree list | cut -d' ' -f1 | xargs ls -ldtr
>
> lists the worktree directories by modification time. The last is the one
> that was modified most recently. That should help your memory.
>
> -- Hannes
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Feature request: support listing worktrees sorted by creation time
2026-03-05 7:14 Feature request: support listing worktrees sorted by creation time Norbert Kiesel
2026-03-05 7:35 ` Johannes Sixt
@ 2026-03-05 15:50 ` Junio C Hamano
2026-03-05 23:36 ` Norbert Kiesel
2026-03-06 13:02 ` Erik Cervin Edin
1 sibling, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2026-03-05 15:50 UTC (permalink / raw)
To: Norbert Kiesel; +Cc: Git Mailing List
Norbert Kiesel <nkiesel@gmail.com> writes:
> I have multiple repos with more than 20 worktrees, and sometimes
> forget the name of a recently added worktree. Therefore it would
> really be nice if I could use something like ‘git worktree list
> —created’ to list them by their creation timestamp. Is that something
> that makes sense to you as well? I could also create a pull request
> for this if you would like it.
I do not think we have any _record_ of when each of these worktrees
was created, so this is not a realistic request.
The output from "git worktree list" may be more than 20 lines, but
isn't your terminal taller than 20 lines ;-)?
Since very early days of Git, we have created .git/description file
that is not used very much (I think it is shown in gitweb). Perhaps
worktree should have an equivalent in per-worktree part of their
.git/ directory and "git worktree list --verbose" can use its
contents in addition to the additional pieces information it already
shows, or something like that, perhaps?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Feature request: support listing worktrees sorted by creation time
2026-03-05 15:50 ` Junio C Hamano
@ 2026-03-05 23:36 ` Norbert Kiesel
2026-03-06 13:02 ` Erik Cervin Edin
1 sibling, 0 replies; 6+ messages in thread
From: Norbert Kiesel @ 2026-03-05 23:36 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
Wrote a Zsh script that uses the "directory create time" but when a
worktree is moved then that will be updated. So would still like to
have `git worktree add` store the current timestamp somewhere.
```zsh
#!/bin/zsh
# List git worktrees with creation timestamps, sorted oldest to newest
wt_path="" branch=""
typeset -a ts_arr wt_arr br_arr
flush() {
[[ -z $wt_path ]] && return
local epoch=$(stat -f '%B' "$wt_path" 2>/dev/null)
ts_arr+=("${epoch:-0}")
wt_arr+=("$wt_path")
br_arr+=("${branch:-(detached)}")
wt_path="" branch=""
}
while IFS= read -r line; do
case $line in
worktree\ *) flush; wt_path=${line#worktree } ;;
branch\ *) branch=${line#branch refs/heads/} ;;
detached) branch="(detached)" ;;
"") flush ;;
esac
done < <(git worktree list --porcelain)
flush
# Find max branch width for column alignment
integer max_br=0
for br in "${br_arr[@]}"; do
(( ${#br} > max_br )) && max_br=${#br}
done
# Print first entry (main worktree) always first
printf "%s %-${max_br}s %s\n" "$(date -r "${ts_arr[1]}"
+"%Y-%m-%d")" "${br_arr[1]}" "${wt_arr[1]}"
# Collect remaining entries prefixed with epoch for numeric sort
typeset -a rest_lines
for (( i=2; i<=${#ts_arr}; i++ )); do
rest_lines+=("${ts_arr[$i]} $(printf "%-${max_br}s %s"
"${br_arr[$i]}" "${wt_arr[$i]}")")
done
# Sort numerically by epoch, then replace epoch with formatted date
(( ${#rest_lines} > 0 )) && print -l "${(on)rest_lines[@]}" | while
IFS= read -r line; do
epoch=${line%% *}
printf "%s %s\n" "$(date -r "$epoch" +"%Y-%m-%d")" "${line#* }"
done
```
On Thu, Mar 5, 2026 at 7:50 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Norbert Kiesel <nkiesel@gmail.com> writes:
>
> > I have multiple repos with more than 20 worktrees, and sometimes
> > forget the name of a recently added worktree. Therefore it would
> > really be nice if I could use something like ‘git worktree list
> > —created’ to list them by their creation timestamp. Is that something
> > that makes sense to you as well? I could also create a pull request
> > for this if you would like it.
>
> I do not think we have any _record_ of when each of these worktrees
> was created, so this is not a realistic request.
>
> The output from "git worktree list" may be more than 20 lines, but
> isn't your terminal taller than 20 lines ;-)?
>
> Since very early days of Git, we have created .git/description file
> that is not used very much (I think it is shown in gitweb). Perhaps
> worktree should have an equivalent in per-worktree part of their
> .git/ directory and "git worktree list --verbose" can use its
> contents in addition to the additional pieces information it already
> shows, or something like that, perhaps?
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Feature request: support listing worktrees sorted by creation time
2026-03-05 15:50 ` Junio C Hamano
2026-03-05 23:36 ` Norbert Kiesel
@ 2026-03-06 13:02 ` Erik Cervin Edin
1 sibling, 0 replies; 6+ messages in thread
From: Erik Cervin Edin @ 2026-03-06 13:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Norbert Kiesel, Git Mailing List
On 26/03/05 07:50AM, Junio C Hamano wrote:
>
> Since very early days of Git, we have created .git/description file
> that is not used very much (I think it is shown in gitweb). Perhaps
> worktree should have an equivalent in per-worktree part of their
> .git/ directory and "git worktree list --verbose" can use its
> contents in addition to the additional pieces information it already
> shows, or something like that, perhaps?
>
I think that sounds like a nice addition. I frequently name the worktree
to encode the intent of the worktree, but that can be a bit clunky.
Having a way to describe it and/or metadata sounds nice!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-06 13:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 7:14 Feature request: support listing worktrees sorted by creation time Norbert Kiesel
2026-03-05 7:35 ` Johannes Sixt
2026-03-05 7:41 ` Norbert Kiesel
2026-03-05 15:50 ` Junio C Hamano
2026-03-05 23:36 ` Norbert Kiesel
2026-03-06 13:02 ` Erik Cervin Edin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox