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

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

From
Maciej Ciemborowicz <maciej.ciemborowicz@gmail.com>
Date
Oct 3, 2026, 18:47 UTC
Message-ID
<20261003184725.29917-1-maciej.ciemborowicz@gmail.com>
In-Reply-To
<xmqqtsp9tyu0.fsf@gitster.g>
Hi Junio,

Thank you for the detailed explanation. I agree that a wrapper is the right answer when the user controls the invocation of `git worktree`.

I tried that approach for a tool I am building: it creates an isolated container environment for each worktree. This matters in particular for projects with databases and migrations, where two agents working in parallel must not share an environment.

The problem is that, in this case, the worktree is often created by the IDE rather than by the user or the agent. For example, Codex in VS Code creates worktrees itself when it starts parallel agent sessions. A `git-wt` wrapper is therefore bypassed, and asking agents to use one does not help: by the time an agent begins work, the worktree may already exist and its environment needs to have been provisioned.

It is possible to approximate this with polling or instructions in an AGENTS.md file, but neither provides a reliable lifecycle boundary. There is a race between worktree creation and the agent beginning work, and cleanup on removal has the same issue.

So I wanted to report a concrete case where wrappers do not reach the actor that performs the operation. This has also been the most consistent feedback I have heard from people using parallel AI agents: they do not want to replace every worktree caller with a wrapper; they need a repository-local way to react when Git creates, moves, or removes a worktree.

Best regards, Maciej Ciemborowicz

Previous: Domen KožarNext: Domen Kožar
Message 10 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.