Generate the exact sequence of Git commands for a described scenario, such as undoing a commit, with the resulting state after each command.
You are a Git tutor who treats every command as something with a real, specific effect on your repository's history, and refuses to hand over a command sequence without saying what state it leaves things in afterward. My scenario is [SCENARIO], described in plain language, exactly what I'm trying to do, such as I committed to the wrong branch and need to move that commit, I need to undo my last commit but keep the changes, or I have a merge conflict and don't know which version to keep. If I left that blank, ask me to describe the situation instead of picking a generic Git scenario to walk through in its place. My current state is [CURRENT_STATE?], anything relevant about where things stand right now, such as whether the commit has already been pushed to a shared remote, since a command that's safe on local-only history can rewrite history other people depend on once it's pushed. If I left that blank and [SCENARIO] involves anything that could be destructive, ask specifically whether the work has been pushed before giving a final answer, instead of assuming either way. Give the exact sequence of commands needed for [SCENARIO], numbered in the order to run them, each one on its own line exactly as it should be typed. After the full sequence, go back through it command by command and explain what that specific command changes, working tree, staging area, local history, or the remote, and what the repository looks like immediately after that command runs. If [SCENARIO] has more than one valid approach, such as reset versus revert for undoing a commit, name the one that fits [CURRENT_STATE] best, and explain in one or two sentences why the other approach would be riskier or wrong for this specific situation instead of listing every option neutrally. If any command in the sequence is destructive or hard to undo, rewriting pushed history, discarding uncommitted changes, mark that specific line clearly before the sequence starts and state exactly what would be permanently lost if it goes wrong, before I run anything. If I report that a command didn't do what you said, ask what the actual output or error message was, then diagnose from that exact message instead of re-explaining the original sequence.
Use this prompt anywhere
10,000+ expert prompts for ChatGPT, Claude, Gemini, and wherever you use AI.
Get Early AccessA generic list of Git commands doesn't help when you're staring at a merge conflict at 11pm. This tool starts from your exact situation, committed to the wrong branch, need to undo a commit, stuck in a conflict, and gives the exact command sequence for it, with a warning up front on anything that could be destructive.
Describe [SCENARIO] in plain language and add [CURRENT_STATE] if it matters, especially whether the work has already been pushed, since a command that's harmless on local-only history can rewrite history someone else depends on once it's shared. The output gives the numbered command sequence first, then walks back through it command by command explaining what each one actually changes, working tree, staging area, local history, or the remote. Where more than one approach exists, reset versus revert, for example, it picks the one that fits your actual situation and says why the other one would be riskier here specifically.
Anything destructive gets flagged before the sequence starts, with exactly what would be lost if it goes wrong. Report back that a command didn't behave as expected and it diagnoses from the real error message instead of repeating the same explanation. Pair it with the command line task explainer for anything outside Git itself, or check an unfamiliar term in the programming term definition explainer.
Run it in the Dock Editor to keep a running log of Git situations you've solved.
Load the prompt into the Dock Editor or your chat tool of choice, then fill in [SCENARIO] in plain language, the actual situation you're in, not the Git term for it, since you might not know the term yet.
Fill in [CURRENT_STATE] with anything that matters, especially whether the commit or branch in question has already been pushed to a shared remote.
A numbered list of the exact commands to run, in order, exactly as they should be typed, no placeholder syntax to decode.
Every command gets explained afterward, what it affects, working tree, staging, local history, or remote, and what your repo looks like right after.
Anything that rewrites pushed history or discards uncommitted work gets flagged clearly before the sequence, with exactly what's at risk if it goes wrong.
Get the exact commands for a real situation, like undoing a bad commit, instead of memorizing a full command reference before you actually need most of it.
Resolve a merge conflict or fix a mis-targeted commit without losing a teammate's work, with the risk of each command flagged clearly first.
Work through common scenarios, branching, rebasing, resolving conflicts, in a safe practice repo before those same situations show up in a real project.
Get a clear, ordered fix for a specific Git mess instead of scrolling through a dozen contradictory Stack Overflow answers to piece one together.
The commands are accurate, but always check the destructive-command warnings before running anything, especially on a repository shared with others. If you're unsure whether a commit has been pushed, say so in [CURRENT_STATE] and the tool will ask before recommending anything that rewrites shared history.
git reset rewrites history by moving your branch pointer, which is fine for commits nobody else has pulled yet. git revert adds a new commit that undoes a previous one, safe on shared history since nothing gets rewritten. The tool picks the right one for your situation based on whether the work has been pushed.
Yes. Describe the conflict situation and the tool walks through the commands to resolve it, along with an explanation of what a conflict marker means and how to choose which version of the conflicting code to keep, tied to your actual scenario.
Describe what happened and paste the exact error message or output you got. The tool diagnoses from that specific message instead of repeating the original explanation, since the actual error usually points to exactly what state your repository is in now.
No. Describe the situation in plain language, I committed to the wrong branch, I need to undo my last commit, and the tool maps that description to the correct Git concepts and commands itself, instead of requiring you to already know the term for what you're trying to do.
Because the safest fix for the exact same problem changes completely depending on that answer. Rewriting local-only history is low-risk. Rewriting history that's already been pushed and pulled by someone else can cause real conflicts for your teammates, so the tool checks this before recommending anything destructive.
Discover more prompts that could help with your workflow.
Build a small working program that calls a real public API, with the request, response, and API key setup explained step by step.
Explain a core functional programming idea, such as pure functions or immutability, with a broken code example and its fixed version shown side by side.
Explain a built-in math function, square root, power, absolute value, or rounding, covering math and syntax, then generate practice calls to predict before revealing results.
10,000+ expert-curated prompts for ChatGPT, Claude, Gemini, and wherever you use AI. Our extension helps any prompt deliver better results.