Overview
After comparing attempts and choosing the best approach, it’s time to merge those changes into your main branch and clean up temporary worktrees.The Merge Process
Merging Attempts
Via Web UI
1
Review Changes
Open task details → Click on completed attempt
2
Review Diff
Check all file changes carefully:
- Files modified
- Lines added/removed
- Tests passing
3
Approve
Click “Approve & Merge” button
4
Confirm
Confirm merge in dialog:
5
Success
Task moves to “Done” column
Worktree auto-cleaned
Via CLI
Merge Strategies
Fast-Forward Merge (Default)
Clean, linear history:Merge Commit
Preserves attempt branch history:Squash Merge
Combine all commits into one:Pre-Merge Checks
Forge runs automatic checks before merging:Test Suite
Custom Pre-Merge Hooks
Configure in.forge/hooks.yaml:
Handling Merge Conflicts
Detecting Conflicts
Resolving Conflicts
- Manual Resolution
- Interactive Resolution
- Automated Strategies
Post-Merge Actions
Automatic Actions
After successful merge, Forge can:.forge/hooks.yaml
Manual Post-Merge Steps
Common things you might do:Cleanup
Automatic Cleanup (Default)
Forge automatically cleans up after merge:Manual Cleanup
Sometimes you want to keep the worktree:Cleanup Rejected Attempts
Worktree Management
List Worktrees
Remove Worktrees
Clean Orphaned Worktrees
Sometimes worktrees get orphaned (branch deleted but directory remains):Forge runs this automatically, but you can trigger it manually if needed
Rolling Back Merges
Made a mistake? Undo the merge:Immediate Rollback
Revert Merge
After pushing to remote:Merge Best Practices
Always Review First
Never merge without reviewing:
Keep Main Stable
Main branch should always work:
- All tests must pass
- No known bugs
- Builds successfully
- Deployed confidently
Meaningful Commit Messages
Clean Up Regularly
Don’t let worktrees accumulate:Old worktrees waste disk space
Advanced: Partial Merges
Sometimes you want only specific files from an attempt:Integration with CI/CD
Trigger Builds on Merge
.github/workflows/forge-merge.yml
Merge Gates
Require CI checks before merge:.forge/config.json
Troubleshooting
Merge fails with 'detached HEAD'
Merge fails with 'detached HEAD'
Error: “Cannot merge: worktree is in detached HEAD state”Solution:
'Worktree still in use' error
'Worktree still in use' error
Error: “Cannot remove worktree: directory is locked”Solution:
Merge creates huge commit
Merge creates huge commit
Issue: Merge commit contains unintended filesSolution:
- Check
.gitignoreis proper - Ensure
node_modules/not committed - Review files before merge:
- Abort and fix:
Can't push after merge
Can't push after merge
Error: “Updates were rejected because the remote contains work that you do not have locally”Solution:
Cleanup Schedule
Recommended cleanup schedule:Next Steps
Git Worktrees
Understand isolation strategy
Workflows
Complete development workflows
CI/CD Integration
Automate deployments
Troubleshooting
Fix common issues

