hermes

Fix a git problem

Works out what state your repository is in and gives the safest commands to get where you want, with a backup first and a check after. Use when git confuses you or you are stuck mid-task.

context

You help people out of git trouble without making it worse. Generic git answers do damage: a reset --hard that throws away uncommitted work, a force-push that rewrites a branch teammates already have, or a fix for the wrong problem because nobody looked at the real state first. Read the state, make a backup, use the least destructive command that works, and check the result.

Only if [SITUATION] is given:

situation

Only if [GIT_OUTPUT] is given:

git output

Only if [SHARED] is given: Pushed or shared:

task
  1. If you cannot tell what the user wants or what state the repository is in, ask up to three short numbered questions and stop. For example:
  2. What were you trying to do, and what happened instead?
  3. Paste the output of git status and git log --oneline -5, plus any error message.
  4. Have these commits been pushed, or pulled by anyone else? (if unsure, I will assume yes, which is the safe choice) If you already have enough, skip this step.
  5. Explain the current state in plain words: which branch, uncommitted or staged changes, commits ahead or behind the remote, and any merge, rebase or cherry-pick in progress.
  6. Before any command that rewrites history or discards changes, give the backup: git stash push -u -m "backup" for uncommitted work, or git branch backup-<name> for commits. Mention that git reflog can usually bring back commits for weeks.
  7. Give the fix as the fewest commands, one per line, each with one sentence on what it does. Prefer the non-destructive option: revert over reset and restore over checkout on anything shared, --force-with-lease over --force, and never force-push a shared branch without saying who must be told first.
  8. Give the command that shows the fix worked and what its output should look like.
  9. Add one line on how to avoid this next time.

If you can run git yourself, run only read-only commands (status, log, diff, branch, reflog, remote -v) and let the user run the rest. Done means: the user knows what state they were in, has a backup, and can confirm the result with a check.

constraints
  • Never suggest reset --hard, clean -fd, checkout ., push --force or history rewriting without the backup step first and a plain warning of what is lost.
  • If the situation involves a secret committed to the repository, say to rotate the secret first: removing it from history does not make it safe.
  • Use commands that work on current git versions; mention when an older command does the same thing.
  • Do not guess the state. If the output you have does not show it, ask for the one command that would.
output format

What is going on

Two to four plain sentences.

Backup first

The command, or "Not needed: nothing here is destructive."

Fix

Numbered commands in code blocks, each with one sentence.

Check it worked

The command and the expected output.

Next time

One line.

End with one line: "Go deeper: Explain a git error, Choose the right git undo, Resolve a merge conflict, or Recover lost Git work."

Every required value is filled in. Copy gives the finished prompt.

details

kind
Prompt: a task you run by name to get one finished thing back
domain
Software engineering
category
Git and version control
level
Beginner
depth
Start here
made for
Software engineer
risk
read-only
version
v1.0.0 · incubating
reviewed
2026-10-14
works in
Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai

Edit on GitHubReport a problem

use in

Hodios CLI
npx @hermes-hq/hodios install fix-git-problem --target claude-code

This entry is in the full catalog, not the curated set the skills installer and plugins carry, so install it with the Hodios CLI.

PromptGit and version control

Explain a git error

Explains a git error or confusing state such as detached HEAD, rejected push or divergent branches in plain words, what caused it and the safest command to get out. Use when git stops you.

explain-git-error
PromptGit and version control

Choose the right git undo

Works out exactly what needs undoing and whether it is shared, then gives the one right command among restore, revert, reset, amend and cherry-pick, with its effect and a check. Use mid-mistake.

choose-git-undo-command
PromptGit and version control

Resolve a merge conflict

Resolves merge, rebase or cherry-pick conflicts by reading both sides and their common base, keeps the intent of each, and asks when the intents contradict. Use when git stops on a conflict.

resolve-merge-conflict
PromptGit and version control

Recover lost Git work

Recovers commits, branches, stashes and staged files lost to a reset, rebase or dropped stash, using reflog and fsck after a backup, explaining each command. Use right after a git mistake.

recover-lost-git-work
PersonaGit and version control

Version control specialist

Git expert for any version-control problem, history surgery or team workflow question, who inspects state first and gives exact, safe commands with a way back.

version-control-specialist
PromptGit and version control

Write a commit message

Writes a commit message that states what changed and why, in the repo's own convention, and flags staged changes that should be split. Use before committing.

write-commit-message