What this prompt does
This prompt turns a chaotic git situation into a structured rescue plan. You describe your specific problem — a merge conflict mid-rebase, a lost commit after a reset, a detached HEAD — and the template generates ordered, annotated commands with an explicit rollback for each step. The "explain what each command does" instruction in the template is what separates this from just running git reflog yourself in a panic: you understand what you're executing before you run it.
The context block (team size, branch strategy, CI/CD, current state) matters. A solo developer squash-merging into main needs different advice than a 12-person team running Gitflow with protected branches and a deploy pipeline. The prompt forces you to supply that context, so the workflow recommendation it returns is calibrated to your actual situation rather than a generic "use feature branches" non-answer.
The fifth output section — pre-push hooks — is often what prevents the same crisis from recurring. The template explicitly asks for safety checks against force-pushing to protected branches, which is the class of mistake that causes real data loss in team environments.
When to use it
- You are in the middle of a rebase and hit cascading conflicts across 15 commits and do not know whether to
--abort,--skip, or keep resolving. - A teammate ran
git push --forceonmainand you need to recover what was there. - You are designing a branching strategy for a new team and want a workflow matched to your team size and release cadence.
- You have a diverged branch after a long-running feature and need to decide between merge, rebase, or squash before opening a PR.
- You need to cherry-pick a hotfix from a release branch back to main without dragging in unrelated commits.
- You want git aliases and a pre-push hook that blocks
--forceon protected branches before anyone on the team can make that mistake.
Example output
For input: git_situation = "rebasing feature branch onto main, stopped at commit 7 of 14 with conflict in src/config.js", team_size = 4, branch_strategy = "GitHub Flow", ci_cd_setup = "GitHub Actions on PR", current_state = "REBASE in progress, HEAD detached"
IMMEDIATE FIX
Before touching anything:
git status # Confirm which files are conflicted
git diff --diff-filter=U # See only unresolved conflicts
Step 1 - resolve the conflict:
# Edit src/config.js, remove conflict markers, save
git add src/config.js
# Rollback for this step: git checkout -- src/config.js (restores conflict markers, discards your edits)
Step 2 - continue the rebase:
git rebase --continue
# Rollback: git rebase --abort (returns you to pre-rebase state, safe)
ROOT CAUSE
Rebase replays commits one at a time. If src/config.js was modified in main
and also in your branch at the same logical point, every commit touching that
file will conflict. Prevention: rebase onto main more frequently on active branches.
WORKFLOW RECOMMENDATION (GitHub Flow, 4-person team)
- Branch naming: feature/<ticket-id>-short-description, hotfix/<id>
- Merge strategy: squash merge PRs into main (clean history)
- PR: 1 required reviewer, CI must pass
- Release: tag main after each deploy (v2026.06.19)
- Hotfix: branch from main HEAD, PR directly to main, tag immediately after merge
Pro tips
- Set
current_stateprecisely. Paste the output ofgit statusandgit log --oneline -5directly into that field. Vague input like "it's broken" produces vague commands. - Use
workflow_typeto get opinionated output. Specify "trunk-based development" vs "Gitflow" vs "GitHub Flow" — the alias and hook recommendations change meaningfully between these. - Run the rollback commands in a test repo first if the situation involves
reset --hardorpush --force-with-lease. The prompt flags data-loss risk, but validating rollbacks on a throwaway clone takes two minutes and eliminates guesswork on production repos. - Pair with a second prompt pass for the aliases section. Ask ChatGPT to output the aliases as a ready-to-paste block for
~/.gitconfig— the first pass often gives prose descriptions, and the follow-up gets you copy-pasteable config. - The pre-push hook output is shell script. Drop it in
.git/hooks/pre-pushandchmod +xit. If your team uses a shared hooks directory viacore.hooksPath, ask the prompt to generate a version compatible with that setup so it can be committed to the repo.