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
- Call
git-hex-getRebasePlanwithontoset to the target branch (usuallymainororigin/main) to see all commits that will be in the PR. - Call
git-hex-checkRebaseConflictswith the sameontoto 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
rebaseWithPlanwithfixupactions to collapse work-in-progress into meaningful commits. - Separate concerns: Use
splitCommitto break a large commit into focused, reviewable pieces (e.g., separate refactoring from feature work). - Reword for clarity: Use
rebaseWithPlanwithrewordactions to write commit messages that tell the PR's story. - Rebase onto latest main: Use
rebaseWithPlanwithonto: "origin/main"and an empty plan to fast-forward the base.
Phase 3: Push and create the PR
-
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.
- For first push:
-
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
getRebasePlanto 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 )" - Use
Phase 4: Address review feedback
When the user gets review comments and wants to update the PR:
- Make the fix — edit the code as needed.
- Target the right commit — use
git-hex-createFixuppointing at the commit the review comment refers to. This keeps the fix associated with the original change. - Fold it in —
git-hex-rebaseWithPlanwithautosquash: trueto absorb the fixup commit. - 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:
- Rebase child branches after parent is rebased:
git-hex-rebaseWithPlanwithontoset to the rebased parent. - Use
git-hex-checkRebaseConflictsto preview whether the child rebase will conflict. - 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
ghCLI
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 originfirst, then useorigin/mainas theontotarget. --force-with-leasenot--force: The lease check prevents overwriting teammates' pushes.- Review feedback fixups need staging:
createFixuprequires staged changes — remind the user togit addthe fix first. - PR description gets stale after rebase: If you rewrote history, update the PR description to match the new commits.