# Feature request: support listing worktrees sorted by creation time

6 messages from 2026-03-05 to 2026-03-06. Participants: Norbert Kiesel, Johannes Sixt, Junio C Hamano, Erik Cervin Edin.
Thread: https://gitlist.dev/t/65137

## Norbert Kiesel, 2026-03-05 07:14

Subject: Feature request: support listing worktrees sorted by creation time
Message-ID: <CAM+g_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa=Et-gw@mail.gmail.com>
URL: https://gitlist.dev/e/CAM%2Bg_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa%3DEt-gw%40mail.gmail.com

```
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

```

## Johannes Sixt, 2026-03-05 07:35

Subject: Re: Feature request: support listing worktrees sorted by creation time
Message-ID: <264862d1-0f83-4d0b-be11-d8e479c7d8da@kdbg.org>
URL: https://gitlist.dev/e/264862d1-0f83-4d0b-be11-d8e479c7d8da%40kdbg.org
In-Reply-To: <CAM+g_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa=Et-gw@mail.gmail.com>

```
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


```

## Norbert Kiesel, 2026-03-05 07:41

Subject: Re: Feature request: support listing worktrees sorted by creation time
Message-ID: <CAM+g_Nsw52JysCsv-FVznh-RAPxYm0kA=Kj2o+KVB5uZpGA0qg@mail.gmail.com>
URL: https://gitlist.dev/e/CAM%2Bg_Nsw52JysCsv-FVznh-RAPxYm0kA%3DKj2o%2BKVB5uZpGA0qg%40mail.gmail.com
In-Reply-To: <264862d1-0f83-4d0b-be11-d8e479c7d8da@kdbg.org>

```
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
>

```

## Junio C Hamano, 2026-03-05 15:50

Subject: Re: Feature request: support listing worktrees sorted by creation time
Message-ID: <xmqqqzpy46n5.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqqzpy46n5.fsf%40gitster.g
In-Reply-To: <CAM+g_Nt8vZX4NxPvddJxNvSRgdMWQaLg2O9xzAU1pTHa=Et-gw@mail.gmail.com>

```
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?

```

## Norbert Kiesel, 2026-03-05 23:36

Subject: Re: Feature request: support listing worktrees sorted by creation time
Message-ID: <CAM+g_NsX5jdjbhtLznxJ=ZRtJ4ShEAzTHzkjgnidyDr-a2r=kw@mail.gmail.com>
URL: https://gitlist.dev/e/CAM%2Bg_NsX5jdjbhtLznxJ%3DZRtJ4ShEAzTHzkjgnidyDr-a2r%3Dkw%40mail.gmail.com
In-Reply-To: <xmqqqzpy46n5.fsf@gitster.g>

```
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?

```

## Erik Cervin Edin, 2026-03-06 13:02

Subject: Re: Feature request: support listing worktrees sorted by creation time
Message-ID: <aarKxwOiv0XmoS6c@Eriks-MacBook-Pro.local>
URL: https://gitlist.dev/e/aarKxwOiv0XmoS6c%40Eriks-MacBook-Pro.local
In-Reply-To: <xmqqqzpy46n5.fsf@gitster.g>

```
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!

```
