Conflict Resolution
Conflicts happen when changes in your stack overlap with changes in the parent branch. This guide walks you through resolving them.
Predicting Conflicts
Section titled “Predicting Conflicts”Before syncing, you can check if any conflicts will occur:
$ rung sync --check⚠️ Potential conflicts detected:
feat-add-user-api → main • src/api/users.rs (abc1234: "Add user creation")This tells you which branches and files will conflict, and which commits cause them. You can then:
- Prepare by reviewing the conflicting files
- Coordinate with teammates if their changes are involved
- Choose to resolve issues before syncing (e.g., by rebasing interactively)
If no conflicts are predicted, you’ll see:
$ rung sync --check✓ No conflicts foundUnderstanding Conflicts
Section titled “Understanding Conflicts”When you run rung sync and a conflict occurs:
$ rung sync✓ Synced feat-add-user-model✗ Conflict in feat-add-user-api
Conflict in: src/api/users.rs
Resolve the conflict, then run: rung sync --continue
Or abort and restore: rung sync --abortRung pauses at the conflicting branch and waits for you to resolve.
The Resolution Process
Section titled “The Resolution Process”Step 1: Identify the Conflict
Section titled “Step 1: Identify the Conflict”Look at the conflicting files:
git statusUnmerged paths: both modified: src/api/users.rsStep 2: Open the File
Section titled “Step 2: Open the File”Open the conflicting file. You’ll see conflict markers:
fn get_user(id: u64) -> User {<<<<<<< HEAD // Code from the new parent (main or parent branch) database.find_user(id)======= // Your code from this branch let user = database.get_user_by_id(id); cache.store(user.clone()); user>>>>>>> feat-add-user-api}Step 3: Resolve the Conflict
Section titled “Step 3: Resolve the Conflict”Edit the file to combine both changes correctly:
fn get_user(id: u64) -> User { // Combined: use new API but keep caching let user = database.find_user(id); cache.store(user.clone()); user}Remove all conflict markers (<<<<<<<, =======, >>>>>>>).
Step 4: Stage the Resolution
Section titled “Step 4: Stage the Resolution”git add src/api/users.rsStep 5: Continue the Sync
Section titled “Step 5: Continue the Sync”rung sync --continueRung continues rebasing the remaining branches.
If More Conflicts Occur
Section titled “If More Conflicts Occur”The sync might pause again at another branch:
$ rung sync --continue✓ Synced feat-add-user-api✗ Conflict in feat-add-user-tests
Conflict in: tests/user_test.rsRepeat the resolution process for each conflict.
Aborting
Section titled “Aborting”If you want to give up and restore everything:
rung sync --abortThis restores all branches to their pre-sync state using the backup refs.
Common Conflict Patterns
Section titled “Common Conflict Patterns”Import Conflicts
Section titled “Import Conflicts”When both sides add imports:
<<<<<<< HEADuse crate::services::UserService;use crate::models::User;=======use crate::models::User;use crate::cache::UserCache;>>>>>>> feat-add-user-apiResolution: Keep all unique imports:
use crate::cache::UserCache;use crate::models::User;use crate::services::UserService;Function Signature Changes
Section titled “Function Signature Changes”When both sides modify the same function:
<<<<<<< HEADfn create_user(name: &str, email: &str) -> User {=======fn create_user(data: UserData) -> Result<User, Error> {>>>>>>> feat-add-user-apiResolution: Decide which signature is correct and update the body accordingly.
File Moved/Deleted
Section titled “File Moved/Deleted”If the parent deleted or moved a file you modified:
CONFLICT (modify/delete): src/old_file.rs deleted in HEADResolution: Either recreate your changes in the new location or git rm the file if the changes are no longer needed.
Prevention Strategies
Section titled “Prevention Strategies”Keep Stacks Small
Section titled “Keep Stacks Small”Smaller stacks = fewer conflicts. Aim for 3-5 branches per stack.
Sync Frequently
Section titled “Sync Frequently”Don’t let your stack drift too far from main:
# Do this dailygit checkout main && git pull && rung syncAvoid Overlapping Work
Section titled “Avoid Overlapping Work”If two people are modifying the same files, coordinate:
- Split work differently
- Use separate stacks
- Merge one stack before starting another
Conflict During Merge
Section titled “Conflict During Merge”Sometimes conflicts happen during rung merge when rebasing child branches:
$ rung merge✓ Merged PR #41✗ Conflict rebasing feat-add-user-api onto main
Resolve the conflict, then run: rung sync --continueThe resolution process is the same.
Using VS Code
Section titled “Using VS Code”If you use VS Code, it has built-in merge conflict resolution:
- Open the conflicting file
- Click “Accept Current Change”, “Accept Incoming Change”, or “Accept Both Changes”
- Or manually edit the combined result
- Save the file
Then:
git add .rung sync --continueUsing Git Mergetool
Section titled “Using Git Mergetool”You can use git’s built-in mergetool:
git mergetoolThis opens your configured merge tool. After resolving:
rung sync --continueChecking for Problems
Section titled “Checking for Problems”After resolving:
# Make sure nothing is brokencargo build # or your build commandcargo test # run tests
# Then continuerung sync --continueTroubleshooting
Section titled “Troubleshooting””Not in a rebase”
Section titled “”Not in a rebase””If you see this error:
$ rung sync --continueError: Not currently in a rebaseThe rebase may have been completed or aborted outside of rung. Run:
rung statusTo see the current state.
Lost My Changes
Section titled “Lost My Changes”If you accidentally lost changes during conflict resolution:
# Find your old commitgit reflog show feat-add-user-api
# Cherry-pick or reset to recovergit cherry-pick abc123Sync State Stuck
Section titled “Sync State Stuck”If the sync state file exists but you’re not in a rebase:
rm .git/rung/sync_state.jsonThen run rung status to check the current state.
Related
Section titled “Related”- Sync command — Full sync documentation
- Undo command — Restore from backup
- Basic workflow — Daily patterns