Loading...
Loading...
[Git] Resolve git merge/cherry-pick/rebase conflicts with backup, analysis, and reporting
npx skill4agent add duc01226/easyplatform git-conflict-resolveplans/reports/conflict-resolution-{date}-{operation}-{source}.md.ai/workspace/conflict-backups-{date}/# Detect operation type
git status # Check for "cherry-pick in progress", "merge in progress", etc.
# List all conflicted files
git diff --name-only --diff-filter=U # Unmerged files (both modified)
git status --short | grep "^DU\|^UD\|^UU\|^AA\|^DD" # All conflict typesmkdir -p {BACKUP_PATH}
# For each conflicted file, copy WITH conflict markers preserved
cp <conflicted-file> {BACKUP_PATH}/<filename>.conflict# For UU conflicts: read the file with conflict markers
# Look for <<<<<<< HEAD / ======= / >>>>>>> markers
# For DU conflicts: get the source version
git show <source-commit>:<file-path>
# Optionally extract clean versions
git show HEAD:<file-path> > {BACKUP_PATH}/<filename>.ours
git show <source-commit>:<file-path> > {BACKUP_PATH}/<filename>.theirs| Conflict Pattern | Resolution Strategy |
|---|---|
| DU: File needed by feature | Accept theirs (add the file) |
| DU: File not needed | Keep ours (skip the file) |
| UU: Non-overlapping changes | Merge both (keep all changes) |
| UU: Overlapping, source modifies methods not on target | Keep ours if methods don't exist on target |
| UU: Overlapping, both modify same method | Manual merge with careful analysis |
| UU: Schema/snapshot files | Accept theirs for new entities, merge for modified |
# Accept theirs (source version)
git checkout --theirs <file> && git add <file>
# Keep ours (target version)
git checkout --ours <file> && git add <file>
# Manual merge: Edit the file to remove conflict markers, then:
git add <file><<<<<<< HEAD=======>>>>>>> <commit>git diff --check# Check no unmerged files remain
git diff --name-only --diff-filter=U
# Check no leftover conflict markers
git diff --check
# Review overall status
git status# For cherry-pick
git cherry-pick --continue --no-edit
# For merge
git commit # (merge commit is auto-prepared)
# For rebase
git rebase --continue{REPORT_PATH}| Risk | Criteria | Action |
|---|---|---|
| Low | New file, no existing code affected | Proceed |
| Medium | Method changes, caller compatibility uncertain | Flag in report, recommend build verification |
| High | Breaking changes, cross-service impact | Require user confirmation before proceeding |
git diff <commit>^..<commit> -- <file>