Merge a worktree into your project
Bring a worktree's committed changes into your project's main folder. If both changed the same files, an agent can finish the merge for you.
Before you start
- Use the Enjoy computer app on the computer that has the project. The web app and the iPhone app don’t merge worktrees.
- Ask the worktree’s agent to commit its work. Changes that aren’t committed are left out of the merge.
- Your project’s main folder has no uncommitted changes to files that were committed before. Otherwise, Merge isn’t available.
- No agent is working in the worktree or in the project’s main folder.
Steps
Select Merge into your project
In a conversation working in the worktree, select Merge into followed by your project’s name, on the band at the top of the message box. Or, in the conversation list, open the three-dot menu on the worktree’s heading and choose Merge into your project.
Review the changes
The window lists the files the merge brings in, with the lines added and removed. Delete the worktree after merging is selected. Clear it if you want to keep working in the worktree.
Select Merge
Enjoy brings the worktree’s commits into the branch your main folder is on. The worktree’s conversations note it, such as “Merged dark-mode into main.”
If Git can’t combine them, ask the agent
When both versions changed the same files, the window says Both versions changed these files and lists them. Nothing has changed yet. Select Ask the agent to merge. Enjoy asks the agent to finish the merge in your main folder, keeping both changes where they fit together, and to ask you about anything it can’t decide.
Good to know
- With Delete the worktree after merging selected, Enjoy removes the worktree’s folder and its branch after the merge. Its conversations continue in the main folder. Any files in the worktree that weren’t committed are deleted with it.
- From the conversation list, the button in step 4 says Ask an agent to merge and starts a new conversation for the merge.
- If your project already has everything from the worktree, the window says so and Merge isn’t available. You can delete the worktree instead.
- Merging changes the files in your main folder, so every conversation there works with the merged files from then on.
If something goes wrong
Your project has changes that aren’t committed
The window says your project “has changes that aren’t committed. Commit them before merging.” and Merge isn’t available. Select Cancel, ask an agent in a main-folder conversation to commit them, then open the merge window again.
If the changes appeared after the window opened, merging stops with “Commit the changes on” your main folder’s branch “in the main project folder before merging.” Nothing was merged. Commit them the same way, then merge again.
Some files aren’t committed in the worktree
The window says how many files aren’t committed in the worktree yet, so the merge leaves them out. Select Cancel, ask the worktree’s agent to commit them, then merge again.
“Stop the work in this worktree before merging it.”
An agent is working in the worktree. Wait for it to finish, or stop it.
“Stop active work in this project to change branches.”
An agent is working in your main folder. Wait for it to finish, then merge.
“Switch the main project folder to a branch before merging.”
Your main folder isn’t on a branch. Choose one in the branch menu, then merge.
“Switch this worktree to a branch before merging.”
The worktree isn’t on a branch, which can happen when its agent goes back to an earlier commit. Ask the worktree’s agent to switch it back to its branch, then merge again.
“This worktree’s branch no longer exists.”
The branch the worktree was using was deleted. Ask the worktree’s agent to put its work on a branch again, then merge.
“This worktree and the main project folder are on the same branch.”
There’s nothing to merge into, because both folders are on one branch. In the branch menu, switch the main project folder to the branch you want the work in, then merge again.