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
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
Use GIT_EDITOR=true for non-interactive git rebase operations
Set environment variables inline to avoid prompts during automation
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_EDITOR=true 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_EDITOR=true 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
]]>
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 with GIT_EDITOR=true
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_EDITOR=true git rebase --continue
execute_command - Verify clean status
Git commands waiting for interactive input
Use GIT_EDITOR=true to bypass editor prompts
Set GIT_SEQUENCE_EDITOR=true for sequence editing
Consider --no-edit flag for commit operations
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 apply_diff with precise search blocks; split into multiple targeted edits if needed
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
Prefer apply_diff with precise search blocks
Ensuring git operations run without requiring user interaction is critical
for automated conflict resolution. The mode uses environment variables to
bypass interactive prompts.
Set to 'true' (a no-op command) to skip editor prompts
GIT_EDITOR=true git rebase --continue
During rebase operations that would normally open an editor
Skip interactive rebase todo editing
GIT_SEQUENCE_EDITOR=true git rebase -i HEAD~3
When interactive rebase is triggered but no editing needed
Use flags to avoid interactive prompts
git commit --no-edit (use existing message)
git merge --no-edit (skip merge message editing)
git cherry-pick --no-edit (keep original message)
Always test commands locally first to identify potential prompts
Combine environment variables when multiple editors might be invoked
Document why non-interactive mode is used in comments
Have fallback strategies if automation fails