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

Re: [PATCH v2 0/4] worktree: add lifecycle hooks

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
Sep 7, 2026, 18:18 UTC
Message-ID
<de83b791-92ae-41a1-8ecf-5abce7893998@app.fastmail.com>
In-Reply-To
<b10f2706-67bb-4657-8d7c-819a29dff890@mtasv.net>
On Mon, Sep 7, 2026, at 16:30, Domen Kožar wrote:
Show 8 quoted lines
> A gentle ping on the single "post-worktree" hook proposal below.
>
> As coding agents increasingly create and discard worktrees, reliable
> lifecycle notifications matter more because tools managing environments
> and cleanup cannot control every caller invoking Git.
>
> Would this interface address your concerns? I'm happy to prepare v3 if
> we can agree on the direction.

The problem is multiple callers invoking Git with different intentions. What if `git worktree add` learned an option `--id=<string>` which is then stored in the worktree? This would communicate that whoever calls git-worktree(1) commands with this ID is the one who owns it.[1] git-worktree(1) commands which do not get an `--id` (and specifically that ID) does nothing to owned worktrees.

[1]: You know, among friendly and cooperating processes.

Then you don’t need hooks for adding, removing, pruning and whatever else.

I could imagine an agent tool that uses it’s own ID to manage a pool of worktrees.

I could imagine more metadata, like recording a timestamp for worktree expiry... but you don’t need anything more in git-worktree(1) itself if you have this ID concept. Then you can let tools implement it themselves. They won’t have their worktrees bothered/clobbered by other tools, so they can manage the whole lifecycle in peace.

Previous: Domen KožarNext: Domen Kožar
Message 8 of 21 in “worktree: add post-worktree-add and post-worktree-remove hooks”
  1. 0/3 worktree: add post-worktree-add and post-worktree-remove hooksDomen Kožar, Jul 9, 2026
  2. Phillip WoodJul 10, 2026
  3. 0/4 worktree: add lifecycle hooksDomen Kožar, Aug 4, 2026
  4. Caleb WhiteAug 4, 2026
  5. Junio C HamanoAug 4, 2026
  6. Domen KožarAug 30, 2026
  7. Domen KožarSep 7, 2026
  8. Kristoffer HaugsbakkSep 7, 2026
  9. Domen KožarSep 7, 2026
  10. Maciej CiemborowiczOct 3, 2026
  11. 0/2 worktree: add post-worktree lifecycle hookDomen Kožar, Oct 4, 2026
  12. Junio C HamanoOct 5, 2026
  13. Phillip WoodJul 13, 2026
  14. 1/4 worktree: add post-worktree-add hookDomen Kožar, Aug 4, 2026
  15. Caleb WhiteAug 4, 2026
  16. 4/4 worktree: add post-worktree-move hookDomen Kožar, Aug 4, 2026
  17. 2/4 worktree: add post-worktree-remove hookDomen Kožar, Aug 4, 2026
  18. 3/4 worktree: run post-worktree-remove hook when pruningDomen Kožar, Aug 4, 2026
  19. 1/2 worktree: add post-worktree lifecycle hookDomen Kožar, Oct 4, 2026
  20. Phillip WoodOct 6, 2026
  21. 2/2 worktree: notify post-worktree hook when pruningDomen Kožar, Oct 4, 2026

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.