A branch is a copy of your app where you can build and test changes without touching the live version. Each branch has its own isolated backend, so the Agent can work in parallel while your main app stays untouched. When you're happy with the result, merge the branch back into main. If you don't want the changes, don't merge: nothing on a branch reaches your main app until you merge it.
When should I use a branch?
Use a branch when you want to try changes safely, away from your main app:
- Test a risky change or large rework before it reaches your main app
- Let the Agent work on a feature in the background while you keep building on main
- Try changes against a copy of your real data without affecting production
- Run several efforts in parallel, each on its own branch
For trying changes against throwaway data on a separate backend, see Environments. For running multiple Agents at once, see Multi-Agent.
How do I create a branch?
- Open your app in the Dashboard
- In the chat, click Branches (the branch icon next to New Chat)
- Click New branch
- Enter a Branch name
- Optionally turn on Replicate production data to copy your production database into the branch
- Click Create branch
Hercules creates the branch with its own isolated backend. Branch names must be unique, you can't reuse the name of a branch that's already open.
How do I switch to a branch?
- In the chat, click Branches
- Type the branch name in the search box to find it
- Click the branch to open its most recent chat
- Check the banner above the message box. It shows Branch: followed by the branch name.
To start a fresh chat on that branch, click New Chat in Branch in the chats sidebar. To go back to your main app, click Branches → main.
A chat you opened on main stays on main. Switching branches doesn't move it, so open the branch's chat before you ask the Agent for changes on the branch.
What can I do on a branch?
A branch works like any other chat. You can:
- Chat with the Agent and ask for changes
- See a live preview of the branch as the Agent works
- View the diff (the list of files the branch has changed compared to main)
- Open more than one chat on the same branch, they share the same backend and code
The preview header shows the branch name and a Merge button so you can merge without leaving the preview.
How do I merge a branch into main?
Click Merge in the branch banner above the chat input. Merge brings your main app's latest changes into the branch, then merges the branch into your main app in the same click. To review the combined result first, ask the Agent to bring your main app's latest changes into the branch, then check Code diff and the branch preview. When the merge finishes, you'll see Merged into main and a "Branch merged into main" confirmation.
After a merge, the branch is done:
- Its changes are now part of your main app
- The chat for that branch can no longer be continued
To keep building, start a new chat on main or create a new branch.
What happens if there are merge conflicts?
A conflict happens when the branch and your main app both changed the same thing. If Hercules can't merge cleanly, the banner changes to Resolve merge conflicts and shows which files conflict. Nothing reaches your main app until you ask the Agent to resolve them and click Merge into main branch.
Additional FAQ
What states can a branch be in?
A branch is one of three states:
- Open. Active and being built. You can chat on it or merge it.
- Resolving. A merge started but hit conflicts. Resolve them, then complete the merge.
- Merged. The changes are now in your main app. The branch is finished.
Merged is final. To keep building, start a new chat or branch.
Can I reopen a merged?
No. Once a branch is merged it's finished, and its chat can't be continued. Start a new chat on main, or create a new branch to keep building.
Which version does Merge use?
Merge uses the latest saved version of the branch. Before merging, Hercules saves any unsaved changes on the branch and brings in the latest main, so everything you see on the branch is included. To check what will be added to main, click Code diff next to Preview. Merging doesn't publish your website, so your live site keeps its current version until you publish. Backend changes (functions, schema and indexes) don't wait for Publish. If your main app uses your production backend, which is the default, they go live there the next time your main dev session starts, for example when you open your app's preview. Your live site starts using them right away, so publish soon after merging. If your app has a development deployment, Publish sends backend changes to production instead.
Can multiple chats work on the same branch?
Yes. After you create a branch, the New Chat in Branch button starts another chat on it. All chats on the same branch share the same backend and code, so changes from one show up for the others.
What does “Replicate production data” do?
It copies your production database into the branch when the branch is created, so you can test against a copy of real data. The copy is a one-time snapshot, changes you make on the branch afterward don't affect production. The option is only available if your app has a production deployment. See Environments and Database.
Does merging copy my branch's data into production?
No. Merging brings over your branch's code and schema changes only. Data in the branch's database never reaches production. After the merge, Hercules deletes the branch's backend along with its database.
Which secrets does a branch get?
A branch gets every secret you've scoped to Development. Secrets scoped only to Production stay off branches. You can't scope a secret to one branch: adding, changing, or removing a Development secret applies to every branch. See Secrets.
Do crons run on a branch?
Yes. A new branch starts from your main app's latest saved code. When the branch's backend is ready, Hercules loads that code into it, and the crons in it start running there, against the branch's own database and secrets. To stop them, pause the branch's deployment (see Environments), or ask the Agent to remove them on the branch. Crons on a branch send real emails and messages, so pause them before you test if you don't want that.
How is a branch different from version control?
Version control tracks every change to your main app in sequence so you can revert. A branch is a separate, isolated copy where you build changes in parallel, then merge them back into main in one step. Use a branch to work safely off to the side, use version history to step back to an earlier point.
How do I get rid of a branch I don't want?
There is no way to delete or close a branch yet. Leave it unmerged: nothing on it reaches your main app. To hide it, click Branches, hover the branch, open Branch actions, and click Archive. Archiving hides the branch's chats, and Unarchive in the same menu brings them back.
Is there a limit on branches?
Each app can have up to 100 branches over its lifetime. Merging branches you're done with keeps you well under the limit.
What happens to the preview after I merge?
The branch's backend is shut down, so its live preview stops. In its place you'll see a notice explaining what happened. Your main app's preview is unaffected.