execute_command
For all git and gh CLI operations
Git commands provide the historical context needed for intelligent resolution
read_file
To examine conflicted files and understand the conflict structure
Need to see the actual conflict markers and code
apply_diff or search_and_replace
To resolve conflicts by replacing conflicted sections
Precise editing of specific conflict blocks
Always use gh CLI for GitHub operations instead of MCP tools
Chain git commands with && for efficiency
Use --format options for structured output
Capture command output for parsing
Get PR information
gh pr view [PR_NUMBER] --json title,body,headRefName,baseRefName
Checkout PR branch
gh pr checkout [PR_NUMBER] --force
Fetch latest main branch
git fetch origin main
Rebase onto main to reveal conflicts
git rebase origin/main
Check conflict status
git status --porcelain | grep "^UU"
Get blame for specific lines
git blame -L [start],[end] HEAD -- [file] | cut -d' ' -f1
Get commit message
git log -1 --format="%s%n%n%b" [commit_sha]
Stage resolved file
git add [file_path]
Continue rebase after resolution
git rebase --continue
Read the entire conflicted file first to understand structure
Note line numbers of conflict markers for precise editing
Identify the pattern of conflicts (multiple vs single)
<<<<<<< HEAD - Start of current branch changes
======= - Separator between versions
>>>>>>> [branch] - End of incoming changes
Always escape conflict markers with backslash
Include enough context to ensure unique matches
Use :start_line: for precision
Combine multiple resolutions in one diff when possible
src/feature.ts
<<<<<<< SEARCH
:start_line:45
-------
\<<<<<<< HEAD
function oldImplementation() {
return "old";
}
\=======
function newImplementation() {
return "new";
}
\>>>>>>> feature-branch
=======
function mergedImplementation() {
// Combining both approaches
return "merged";
}
>>>>>>> REPLACE
]]>
Use for simple conflict resolutions
Enable regex mode for complex patterns
Always escape special characters
src/config.ts
\<<<<<<< HEAD[\s\S]*?\>>>>>>> \w+
// Resolved configuration
const config = {
// Merged settings from both branches
}
true
]]>
execute_command - Get PR info with gh CLI
execute_command - Checkout PR with gh pr checkout --force
execute_command - Fetch origin main
execute_command - Rebase onto origin/main
execute_command - Check for conflicts with git status
execute_command - List conflicted files
read_file - Examine conflict structure
execute_command - Git blame on conflict regions
execute_command - Fetch commit messages
read_file - Get exact conflict content
apply_diff - Replace conflict with resolution
execute_command - Stage resolved file
execute_command - Verify resolution status
execute_command - Check all conflicts resolved
execute_command - Continue rebase with git rebase --continue
execute_command - Verify clean status
Rebase completes without conflicts
Inform user that PR can be merged without conflicts
No resolution needed
A rebase is already in progress
Check status with git status
Either continue existing rebase or abort with git rebase --abort
Conflict markers are incomplete or nested
Use search_and_replace with careful regex patterns
Manual inspection may be required
Binary files cannot be merged automatically
Identify which version to keep based on PR intent
Use git checkout --theirs or --ours
Code contains literal conflict marker strings
Extra careful escaping in diffs
Consider using search_and_replace with precise patterns