Git history rewrite and conflict-resolution tools (MCP) with curated skills.

Install

/plugin install git-hex@git-hex-marketplace

Run it inside Claude Code after adding the marketplace with /plugin marketplace add yaniv-golan/git-hex.

Contents

Discovered from source

Skills 3

Git-hex Branch Cleanup

Use this skill when the user wants to reshape a feature branch's commit history using git-hex tools instead of manual interactive rebase.

Workflow

1. Assess the situation

  • Call git-hex-getRebasePlan to see the commit range.
    • Use count to control how far back (default 10, max 200).
    • Commits come back oldest-first — the natural order for a rebase plan.
    • If onto is omitted it defaults to @{upstream} or HEAD~count.
  • Optionally call git-hex-checkRebaseConflicts to predict conflicts before starting. This requires git 2.40+ — if the user's git is older, skip it and note the limitation.

2. Choose the right tool for the job

GoalToolNotes
Edit the last commit (message or content)amendLastCommitUse addAll: true to stage tracked changes automatically. Needs at least staged changes OR a new message.
Fix an older commitcreateFixup → rebaseWithPlanUser must stage changes first. Then createFixup targets the commit; follow with rebaseWithPlan using autosquash: true to fold it in.
Reorder, drop, squash, or rewordrebaseWithPlanPass a plan array. For reordering, set requireComplete: true.
Break a commit into focused piecessplitCommitRequires splits array with ≥2 entries. Every file in the original commit must appear in exactly one split.
Cherry-pick a single commitcherryPickSingleRejects merge commits. Use abortOnConflict: false to pause on conflicts instead of aborting.

3. Execute safely

  • Prefer autoStash: true when the working tree is dirty.
    • rebaseWithPlan uses git's native --autostash.
    • amendLastCommit uses --keep-index mode (preserves staged changes).
    • splitCommit and cherryPickSingle use git-hex's own stash helper.
  • Never rewrite shared or protected branches — only feature branches the user controls.
  • All write operations create backup refs automatically.

4. Handle stash restore failures

Tools that manage their own stash (amendLastCommit, splitCommit, cherryPickSingle) return stashNotRestored: true if the stash pop fails after the operation succeeds. When you see this:

  1. Tell the user their operation succeeded but their stashed changes couldn't be reapplied cleanly.
  2. Suggest running git stash list to find the stash entry, then git stash pop manually to resolve any conflicts.

rebaseWithPlan uses git's native --autostash and does not emit this flag — git handles it internally.

5. Recover from mistakes

  • Call git-hex-undoLast to restore the state before the last git-hex operation.
  • It requires a clean working tree. Use force: true only if commits were added after the backup or untracked files would be overwritten.
  • If a rebase pauses with conflicts, hand off to the git-hex-conflict-resolution skill.

Gotchas

  • reword requires message — without it, git opens an editor and hangs.
  • Messages must be single-line — no TAB or newline characters in message fields for reword, splitCommit, or createFixup.
  • createFixup needs staged changes — it doesn't stage anything itself. Remind the user to git add first.
  • requireComplete: true — when reordering, every commit in the range must appear in the plan. Without this, unmentioned commits default to pick.
  • Prefer fixup over squash unless the user wants to combine commit messages (squash opens an editor-like message merge; fixup silently discards).
  • Root commits can't be split — splitCommit rejects them.
  • Merge commits can't be split or cherry-picked — both tools reject them.
  • Detached HEAD — getRebasePlan and rebaseWithPlan warn about this in their summary. Flag it to the user if unexpected.

Git-hex Conflict Resolution

Use this skill when a git-hex operation is paused due to conflicts — or when the user reports being stuck in a rebase, merge, cherry-pick, or revert.

Workflow

1. Inspect the conflict state

Call git-hex-getConflictStatus to determine:

  • Whether an operation is in progress and what type (rebase, merge, cherry-pick, revert)
  • Which files are conflicting and the conflict type per file
  • For rebases: currentStep / totalSteps progress

When to use includeContent: true:

  • When you need to see the actual base/ours/theirs content to propose a resolution — typically for text files where you'll edit and resolve.
  • Skip it for binary files (they'll be flagged isBinary: true) or when you just need to see the list of conflicting files.
  • Use maxContentSize (default 10000) to limit large files. Content is truncated per-file and marked with truncated: true.

Important: inConflict: true can persist even after all files are resolved if the operation is still paused. Check conflictingFiles length, not just inConflict.

2. Resolve each conflicting file

For text files (both_modified, added_by_both):

  1. Read the conflict content (base/ours/theirs) from the getConflictStatus response or by reading the file directly.
  2. Edit the file to produce the correct merged content. Remove all conflict markers — resolveConflict with resolution: "keep" will reject the file if any <<<<<<<, =======, >>>>>>>, or ||||||| markers remain.
  3. Call git-hex-resolveConflict with file and resolution: "keep".

For delete conflicts (deleted_by_us, deleted_by_them):

  • resolution: "keep" — restores the file (from theirs if deleted_by_us, from ours if deleted_by_them).
  • resolution: "delete" — accepts the deletion.
  • Ask the user which they prefer if the intent isn't clear.

Path rules: The file parameter must be a POSIX repo-relative path. No absolute paths, no ../ traversal, no drive letters.

After each resolution, resolveConflict returns remainingConflicts — the count of files still in conflict.

3. Continue or abort

Continue — when all conflicts are resolved (remainingConflicts: 0) or getConflictStatus shows no remaining conflicting files:

  • Call git-hex-continueOperation.
  • It may return paused: true again if the next commit in a rebase also conflicts. Go back to step 1 in that case.
  • Supports: rebase, cherry-pick, merge. Does not support revert or bisect — for those, suggest git revert --continue / git bisect reset directly.

Abort — if the user wants to abandon the operation:

  • Call git-hex-abortOperation. This restores the pre-operation state.
  • For a rebase initiated by git-hex, git-hex-undoLast is also available as recovery after the operation completes (if the result wasn't what the user wanted).

4. Verify the result

After continueOperation reports completed: true, confirm the state:

  • Use git-hex-getRebasePlan or git log to show the user the final history.
  • If the result isn't right, suggest git-hex-undoLast to roll back.

Conflict types reference

Operation-level

TypeMeaning
rebaseInteractive rebase paused mid-apply
mergeMerge in progress
cherry-pickCherry-pick paused
revertRevert paused (limited tool support — see above)

File-level

TypeMeaningTypical resolution
both_modifiedBoth sides changed the fileEdit to merge, then keep
deleted_by_usWe deleted, they modifiedkeep (restore) or delete
deleted_by_themWe modified, they deletedkeep (restore) or delete
added_by_bothBoth sides added different versionsEdit to merge, then keep

Git-hex PR Workflow

Use this skill when the user wants to go from a messy feature branch to a clean, submitted (or updated) pull request. This skill combines git-hex for local commit shaping with GitHub tools or CLI for remote collaboration.

Workflow

Phase 1: Understand the branch

  1. Call git-hex-getRebasePlan with onto set to the target branch (usually main or origin/main) to see all commits that will be in the PR.
  2. Call git-hex-checkRebaseConflicts with the same onto to predict whether rebasing will be smooth. If conflicts are predicted, warn the user before proceeding — they may want to resolve upstream changes first.

Phase 2: Shape the history

Use the git-hex-branch-cleanup skill techniques to craft a clean, logical commit sequence. Common PR prep patterns:

  • Squash WIP commits: Use rebaseWithPlan with fixup actions to collapse work-in-progress into meaningful commits.
  • Separate concerns: Use splitCommit to break a large commit into focused, reviewable pieces (e.g., separate refactoring from feature work).
  • Reword for clarity: Use rebaseWithPlan with reword actions to write commit messages that tell the PR's story.
  • Rebase onto latest main: Use rebaseWithPlan with onto: "origin/main" and an empty plan to fast-forward the base.

Phase 3: Push and create the PR

  1. Push: git push --force-with-lease (safe force push — refuses if the remote has commits you haven't seen).

    • For first push: git push -u origin <branch>.
    • Never force-push to main/master.
  2. Create or update the PR:

    • Use gh pr create (or the GitHub plugin if installed).
    • Craft the PR description from the commit history: Use the commits from getRebasePlan to build a summary. Each well-crafted commit message becomes a bullet point or section in the PR body.
    gh pr create --title "Short title" --body "$(cat <<'EOF'
    ## Summary
    - First logical change (from commit 1 message)
    - Second logical change (from commit 2 message)
    
    ## Test plan
    - [ ] Verify X
    - [ ] Check Y
    EOF
    )"
    

Phase 4: Address review feedback

When the user gets review comments and wants to update the PR:

  1. Make the fix — edit the code as needed.
  2. Target the right commit — use git-hex-createFixup pointing at the commit the review comment refers to. This keeps the fix associated with the original change.
  3. Fold it in — git-hex-rebaseWithPlan with autosquash: true to absorb the fixup commit.
  4. Push again — git push --force-with-lease.

This produces a clean history where each commit is correct, rather than a trail of "fix review comment" commits.

Phase 5: Handle stacked PRs (advanced)

When working with dependent branches:

  1. Rebase child branches after parent is rebased: git-hex-rebaseWithPlan with onto set to the rebased parent.
  2. Use git-hex-checkRebaseConflicts to preview whether the child rebase will conflict.
  3. Push each branch with --force-with-lease.

Tools to prefer

  • Local craft: All git-hex tools (see branch-cleanup skill for details)
  • Remote: GitHub plugin tools if installed; otherwise gh CLI

Key insight

git-hex handles the local craft — shaping commits into a clean, reviewable story. GitHub tools handle the remote collaboration — creating PRs, adding reviewers, responding to comments. Together they cover the full PR lifecycle.

Gotchas

  • Always fetch before rebasing onto main: git fetch origin first, then use origin/main as the onto target.
  • --force-with-lease not --force: The lease check prevents overwriting teammates' pushes.
  • Review feedback fixups need staging: createFixup requires staged changes — remind the user to git add the fix first.
  • PR description gets stale after rebase: If you rewrote history, update the PR description to match the new commits.

MCP servers 1

Sponsors

Details

Marketplace
yaniv-golan/git-hex
Category
Community