# How to work with worktrees?

**URL:** <https://forum.cursor.com/t/how-to-work-with-worktrees/159255>\
**Category:** Discussions\
**Tags:** worktrees, agents-window\
**Created:** [April 28, 2026, 11:58am UTC](https://forum.cursor.com/t/how-to-work-with-worktrees/159255 "2026-04-28T11:58:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ingvar](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@Ingvar](https://forum.cursor.com/u/Ingvar)\
**Post date:** [April 28, 2026, 11:58am UTC](https://forum.cursor.com/t/how-to-work-with-worktrees/159255/1 "2026-04-28T11:58:28Z")

</div>

I’m trying to get used to a new Cursor3 UI and my goal is to use worktrees in Cursor.  
Can you share how you organize your work with worktrees in Cursor?

- How do you manage .env and other uncommitted files? AFAIK there’s no setup script option for new worktrees
- Does Cursor cleanup worktree after I archive the chat?
- Any best practices making agent aware of worktree environment? For example they always try to use same dev server on port 3000

Any other tips?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [April 28, 2026, 3:06pm UTC](https://forum.cursor.com/t/how-to-work-with-worktrees/159255/4 "2026-04-28T15:06:15Z")

</div>

Hey @Ingvar!

To grab the first two questions you asked:

> [@Ingvar](#):
>
> - How do you manage .env and other uncommitted files? AFAIK there’s no setup script option for new worktrees

There is! Read about it [here](https://cursor.com/docs/configuration/worktrees#how-does-worktree-setup-work).

> [@Ingvar](#):
>
> - Does Cursor cleanup worktree after I archive the chat?

Not directly after archival (you might want to go join [this thread](https://forum.cursor.com/t/cursor-should-cleanup-worktrees-if-chat-was-archived/159174)) but there is a [cleanup mechanism](https://cursor.com/docs/configuration/worktrees#worktrees-cleanup).

---

<div class="post-metadata">

**Author:** ![Ingvar](https://avatars.discourse-cdn.com/v4/letter/i/9dc877/32.png) [@Ingvar](https://forum.cursor.com/u/Ingvar)\
**Post date:** [May 14, 2026, 7:09am UTC](https://forum.cursor.com/t/how-to-work-with-worktrees/159255/7 "2026-05-14T07:09:16Z")

</div>

Thank you @Colin! A life-saver!

TBH it makes sense to at least add a link to the docs in Settings / Worktree  
Or better add Setup Script text area with option to auto-populate it based on project content

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [August 12, 2026, 7:09am UTC](https://forum.cursor.com/t/how-to-work-with-worktrees/159255/9 "2026-08-12T07:09:34Z")

</div>

Closed on August 12, 2026, 7:09am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
