Merge & Conflict Detection Example
Demonstrates pre-merge conflict detection with merge.ConflictDetector.
Merge/rebase execution is intentionally left to plain git (bulk-first identity:
gz-git diagnoses; interactive merge/rebase stays in git).
Features Demonstrated
- Pre-Merge Conflict Detection: Identify conflicts before attempting merge
- Fast-forward check: Whether merge can fast-forward
- CLI pointer:
gz-git conflict detect <source> <target>
Usage
Detect Conflicts Before Merging
# Check for conflicts between branches
gz-git conflict detect feature/mybranch main
# Detailed conflict analysis
gz-git conflict detect feature/mybranch main --detailed
Execute Merge (Git)
# Basic merge
git merge feature/mybranch
# Merge with specific strategy
git merge feature/mybranch --strategy recursive
# Merge without creating commit (for review)
git merge feature/mybranch --no-commit
Abort Merge (Git)
# If merge has conflicts, abort and return to pre-merge state
git merge --abort
Rebase Operations (Git)
# Rebase current branch onto main
git rebase main
# Interactive rebase
git rebase -i main
Merge Strategies
gz-git library supports multiple merge strategies:
- fast-forward: Fast-forward only (no merge commit)
- recursive: Default 3-way merge (Git's default)
- ours: Prefer current branch on conflicts
- theirs: Prefer incoming branch on conflicts
- octopus: Merge multiple branches
Library Usage
For library integration, see Library Guide.
See pkg/merge for complete API documentation.