resolve-git-conflicts
Resolve Git Conflicts
Overview
Resolve Git conflicts end-to-end in the CLI. Analyze base/ours/theirs, decide which changes to keep or combine, verify the code works, then stop for human review before any commit or continue.
Quick Start
git status -sbgit diff --name-only --diff-filter=U- For each file, inspect base/ours/theirs:
git show :1:PATH,git show :2:PATH,git show :3:PATH - Edit files to a clean, marker-free result and run
git add PATH - Run the repo build/tests if available
- Stop for review. Do not run
git commit,git merge --continue,git rebase --continue, orgit cherry-pick --continue
Workflow
- Understand why the conflict happened.
Use
git status -sbandgit log --oneline --decorate -n 20to identify the operation and the competing commits. - Analyze all versions.
Use
git show :1:PATH(base),:2:(ours),:3:(theirs). Usegit diff --ours PATHandgit diff --theirs PATHto see intent. - Resolve conflicts with explicit choices.
Remove markers, choose
ours,theirs, or a combined result based on the decision framework. Prefer minimal, intention-preserving edits. Do not ask the user to edit; apply the changes directly and record the rationale in your response. - Verify the code works. Run the project's build/test/lint commands if defined. If none exist, run the smallest available smoke check.
- Handoff for review.
Stop after changes are staged and verified. Do not
git commit,git merge --continue,git rebase --continue, orgit cherry-pick --continue. Provide a short summary of decisions and files touched for review.
Decision Framework
Do not default to ours or theirs. Decide per file using evidence.
Questions to answer before choosing:
- Which version matches the current API and usage sites?
- Which version aligns with the most recent refactor or commit intent?
- Which version is covered by or fixes failing tests?
- Which version removes deprecated code or references?
- Would combining both introduce duplication or inconsistent behavior?
Interpretation notes:
- In a merge,
oursis the current branch andtheirsis the merged-in branch. - In a rebase or cherry-pick,
oursis the branch you are applying onto andtheirsis the commit being applied. - If still ambiguous, choose the least risky change and state the assumption.
Commands
| Goal | Command |
|---|---|
| List conflicted files | git diff --name-only --diff-filter=U |
| See conflict markers | `rg -n "<<<<<<< |
| Show base/ours/theirs | git show :1:PATH, git show :2:PATH, git show :3:PATH |
| Diff ours vs file | git diff --ours PATH |
| Diff theirs vs file | git diff --theirs PATH |
| Accept ours/theirs quickly | git checkout --ours PATH, git checkout --theirs PATH |
| Stage resolution | git add PATH |
If rg is unavailable, use grep -n "<<<<<<<\\|======\\|>>>>>>>" PATH.
Example
Conflict:
function formatUser(user) {
<<<<<<< HEAD
return `${user.name} <${user.email}>`;
=======
return `${user.displayName} <${user.email}>`;
>>>>>>> feature/use-display-name
}
Resolved (use new field, keep fallback):
function formatUser(user) {
const name = user.displayName ?? user.name;
return `${name} <${user.email}>`;
}
Rationale: the feature branch introduced displayName, but existing callers may still populate name.
Common Mistakes
- Continuing a merge/rebase/cherry-pick before the review handoff.
- Treating
oursandtheirsas fixed to "my branch" and "their branch" in all operations. - Leaving conflict markers or partially resolved blocks in files.
- Auto-accepting one side without inspecting base and usage context.
More from tenfyzhong/skills-hub
analyse-issue
Analyze GitHub issues by link or issue number. Use when a user says "analyse issue"/"analyze issue" or provides a GitHub issue URL/number and asks to fetch the issue content, verify it matches the current repo, and inspect local code to confirm the problem.
12create-pr
Create a Pull Request from the current branch. Syncs upstream main/master, updates current branch, handles fork remotes intelligently, and generates PR title/description from diff and commits. Respects PR templates if present. REQUIRES Must be in a git repository with gh CLI available.
11new-issue
Use when the user asks to create a GitHub issue from the current conversation context (e.g., "new issue", "create issue", "file an issue", bug/feature request) with a target repo given or auto-detected, and gh CLI is available/authenticated.
11pr-review
Comprehensive PR code review skill for git repositories. Use when reviewing a GitHub/GitLab PR by providing a PR link. Analyzes changes against merge base, explains what the PR does, provides review guidelines, identifies issues sorted by severity, evaluates test coverage, and raises uncertain questions. REQUIRES Must be in a git repository with gh CLI available.
11implement-issue
Implement a GitHub issue end-to-end. Accepts issue number or URL, syncs to latest main/master, creates a feature branch, analyzes the issue, explores the codebase thoroughly, and implements the solution. REQUIRES Must be in a git repository with gh CLI available.
11install-nvim-plugin
Install a Neovim plugin configuration from a GitHub URL. Usage '/install-nvim-plugin <github-url>'. Parses the URL, fetches plugin documentation, generates optimal lazy.nvim configuration with lazy loading, and saves to `./lua/plugins/`. Optionally updates README.md.
2