Dirty-main narrow fix promotion with stash recovery
Use when:
- a single verified fix commit must be promoted to
main /mnt/local-analysis/workspace-hubmainis dirty- you also need to create GitHub issues from generated scripts without trusting assumed labels
Core lessons
- Do not cherry-pick onto dirty
main. - Before
gh issue create, verify exact repo labels; do not assume generic labels liketests,parsing, orreleasesexist. git stash push -umay be the right move for a quick narrow promotion, butstash applycan fail after the cherry-pick/push if the restored work overlaps files changed by ongoing local work.- If restore fails, keep the stash; do not drop it. Prefer recovery in isolation rather than forcing restore on dirty
main.
Issue-creation preflight
Run before creating issues:
gh auth status
gh label list --repo <owner/repo>
gh issue list --repo <owner/repo> --state all --search '"<exact proposed title>"' --limit 10
Rules:
- use only labels that actually exist in the target repo
- exact-title search is cheap and catches obvious duplicates
- if a label is missing, patch the local issue-generation scripts before creation
Narrow promotion flow from dirty main
- Inspect dirty state:
cd /mnt/local-analysis/workspace-hub
git status --short --branch
- Stash tracked + untracked state:
git stash push -u -m "pre-<commit>-promotion-YYYY-MM-DD"
- Verify clean enough to proceed:
git status --short --branch
git stash list | head
- Update
mainand verify fix absent:
git fetch origin --prune
git pull --ff-only origin main
if git merge-base --is-ancestor <commit> HEAD; then echo already-present; else echo absent; fi
- Cherry-pick and validate:
git cherry-pick <commit>
bash tests/hooks/test-require-plan-approval.sh
git push origin main
- Restore the stash conservatively:
git stash apply stash^{/pre-<commit>-promotion-YYYY-MM-DD}
Use apply, not pop, so the stash survives failed or partial restore.
If stash apply fails
Symptoms:
Your local changes to the following files would be overwritten by merge- promotion already succeeded and pushed
Response:
- stop immediately
- confirm the promoted fix is on
mainand pushed - confirm the stash still exists with
git stash list - do not drop the stash
- do not continue unrelated work from this dirty
main - recover in isolation:
- preferred: create a recovery branch/worktree from the stash and inspect/merge deliberately
- avoid repeatedly stacking more stash/apply operations on dirty
main
Why this matters
This pattern preserves the narrow promotion audit trail while protecting the original dirty local state. It also avoids GH issue creation failures caused by repo-taxonomy drift between assumed labels and real labels.
Verification checklist
gh auth statushealthy- exact labels verified in target repo
- duplicate-title search returns no exact matches
- fix commit not already on
main - targeted regression test passes after cherry-pick
- push succeeds
- if restore fails, stash still exists and is preserved for isolated recovery