wit provides an improved merge experience with structured conflict resolution.
merge
Merge a branch into the current branch.
wit merge <branch> [options]
Options
| Option | Description |
|---|
--no-commit | Perform merge but don’t create a commit |
--abort | Abort the current merge |
--continue | Continue merge after resolving conflicts |
--conflicts | Show current conflicts |
--resolve <file> | Mark a file as resolved |
Examples
# Merge a branch
wit merge feature-branch
# Merge without auto-commit
wit merge feature-branch --no-commit
Merge Workflow
Simple Merge (No Conflicts)
# Ensure you're on the target branch
wit switch main
# Merge the feature branch
wit merge feature-login
Output:
Merging feature-login into main...
Merge successful!
Merge with Conflicts
When conflicts occur:
Output:
Merging feature-branch into main...
CONFLICT: src/index.ts
CONFLICT: src/config.ts
Automatic merge failed. Fix conflicts and run:
wit merge --continue
Conflict Resolution
View Conflicts
Output:
Conflicting files:
1. src/index.ts (3 conflicts)
2. src/config.ts (1 conflict)
Unlike Git’s inline markers, wit uses structured JSON for conflicts:
{
"file": "src/index.ts",
"conflicts": [
{
"line": 15,
"ours": "const timeout = 5000;",
"theirs": "const timeout = 10000;",
"base": "const timeout = 3000;"
}
]
}
Resolving Conflicts
- Edit the file to fix conflicts
- Mark as resolved:
wit merge --resolve src/index.ts
- Complete the merge:
Abort a Merge
If you want to cancel the merge:
Visual Conflict Resolution
For complex conflicts, use the visual interface:
The web UI provides:
- Side-by-side diff view
- Click to choose “ours” or “theirs”
- Manual editing for custom resolution
- Preview of merged result
Merge Example
Here’s a complete merge workflow:
# 1. Start on main branch
wit switch main
# 2. Attempt merge
wit merge feature-auth
# 3. If conflicts occur, view them
wit merge --conflicts
# 4. Open and edit conflicting files
# (or use wit web for visual resolution)
# 5. Mark files as resolved
wit merge --resolve src/auth.ts
wit merge --resolve src/config.ts
# 6. Complete the merge
wit merge --continue
# 7. Verify the merge
wit log --oneline -n 5
Undo a Merge
Made a mistake? Just undo it:
This works whether the merge:
- Completed successfully
- Is still in progress
- Has conflicts
Merge Strategies
wit currently supports recursive merge strategy (similar to Git’s default). Additional strategies are planned for future releases.
Tips
Before merging, ensure your branch is up to date:wit switch feature-branch
wit status # Check for uncommitted changes
wit switch main
wit merge feature-branch
Don’t use --force unless you really mean it. The undo command is your friend if something goes wrong.