Merge Resolve Workflow
When activated, execute this workflow to update main and merge it into the current branch, resolving any conflicts:
Steps
- •
Check current state: Verify there are no uncommitted changes:
bashgit status --porcelain
If there are changes, commit or stash them first.
- •
Get current branch name:
bashgit branch --show-current
Save this to return to later.
- •
Fetch latest from origin:
bashgit fetch origin
- •
Update main branch:
bashgit checkout main git pull origin main
- •
Return to feature branch:
bashgit checkout <feature-branch>
- •
Attempt merge:
bashgit merge main
If merge succeeds without conflicts:
- •Run tests to verify everything still works
- •Push the merge commit
- •Report success and skip to step 11
- •
If conflicts occur, analyze them:
bashgit status git diff --name-only --diff-filter=U
List all files with conflicts.
- •
For each conflicted file:
- •Read the file to see conflict markers (
<<<<<<<,=======,>>>>>>>) - •Understand what changed in both branches
- •Resolve the conflict by:
- •Keeping the feature branch changes if they're the intended behavior
- •Keeping main branch changes if they're bug fixes or improvements
- •Merging both if compatible
- •Manually editing to combine changes intelligently
- •Remove conflict markers
- •Stage the resolved file:
git add <file>
- •Read the file to see conflict markers (
- •
Verify resolution:
bashjust ci
This runs all CI checks (build, clippy, fmt-check, test, test-e2e).
If tests fail, review and fix the merge resolution.
- •
Complete the merge:
bashgit commit # Complete the merge commit git push
- •
Report summary:
- •List files that had conflicts (if any)
- •Describe how each conflict was resolved
- •Confirm all tests pass
- •Show the merge commit hash
Conflict Resolution Strategy
When resolving conflicts, follow these priorities:
- •Documentation conflicts: Usually safe to keep both changes, manually merge
- •Test conflicts: Keep both tests unless they're testing the same thing
- •Code conflicts:
- •If feature branch adds new functionality: keep feature changes
- •If main has bug fixes: incorporate the bug fix into feature code
- •If both modify same logic: manually merge to preserve both intents
- •Dependency conflicts (Cargo.toml, package.json):
- •Keep the higher version number
- •If both added different deps, keep both
- •Generated code conflicts: Regenerate if possible, otherwise keep feature branch
Example Conflict Resolution
<<<<<<< HEAD (feature branch)
pub fn analyse(module: &Module) -> AnalysisResult {
let mut analyser = Analyser::new();
analyser.analyse_module(module);
analyser.result
}
=======
pub fn analyze(module: &Module) -> AnalysisResult {
// TODO: Implement semantic analysis
AnalysisResult::new()
}
>>>>>>> main
// Resolution: Keep feature implementation, preserve any main branch improvements
pub fn analyse(module: &Module) -> AnalysisResult {
let mut analyser = Analyser::new();
analyser.analyse_module(module);
analyser.result
}
Edge Cases
- •Binary conflicts (Cargo.lock):
git checkout --theirs Cargo.lock && cargo build - •Deleted files: Determine if deletion from main is intentional; if so,
git rm <file> - •Renamed files: Git usually handles automatically; if not, manually apply feature changes to renamed file
- •Merge commit already exists: Skip merge step, just report current state
Error Handling
If merge cannot be resolved automatically:
- •Document the conflict clearly
- •Ask user for guidance on specific conflicts
- •Do not guess or make assumptions about intent
- •If truly stuck, abort merge with
git merge --abortand report the issue