Git Command Generator
Describe what you want to do in git. Get the exact command with an explanation.
Git is powerful but unforgiving, and nobody remembers every flag. When you know exactly what you want to do but not the precise command, this tool bridges the gap: describe the task in plain English and get the exact git command back, with an explanation of what each part does so you learn as you go.
How to use it
- In What do you want to do?, describe your goal in normal language — for example "undo my last commit but keep the changes," or "rename a branch I already pushed."
- Generate, and you'll get the command plus a short explanation of the flags and arguments.
- Read the explanation before running anything, especially for commands that rewrite history or discard work.
- Run the command in your repo, then verify the result with
git statusorgit logto confirm it did what you expected.
When to use it
It's ideal for the situations git makes scary: undoing a commit, recovering a deleted branch, stashing work mid-task, resolving a tangled merge, cleaning up history before a pull request, or cherry-picking a single commit. It's also a fast way to learn — reading the explanation each time builds real fluency. When you hit code you don't understand while resolving a conflict, the code explainer can break it down, and the PgDog guide is worth a read if your workflow touches databases alongside git.
Tips for better results
- Be specific about state. "Discard local changes to one file" and "discard all local changes" produce very different (and not interchangeable) commands — say which you mean.
- Mention whether you've pushed. Rewriting a commit that's only local is safe; rewriting one you've already shared needs a force push and a warning, so include that detail.
- Name branches and files when relevant so the command comes back ready to paste rather than full of placeholders.
- Ask for the safe version. If you want the option that's hardest to lose work with, say so and you'll get the more conservative command.
Common mistakes to avoid
The biggest risk in git is destructive commands. Never run git reset --hard, git push --force, or git clean -fd from any source — this tool included — without understanding that they can permanently delete uncommitted work. Always read the explanation first, and when in doubt, commit or stash your changes so you have a recovery point. Don't force-push to a shared branch unless your team agrees, since it rewrites history others may have pulled. Avoid copy-pasting a command without checking which branch you're on — running a reset on the wrong branch is a classic, painful mistake. If a command looks more aggressive than your task requires, regenerate with a clearer, narrower description, and prefer --force-with-lease over a plain --force when you must rewrite a pushed branch, since it refuses to clobber work you haven't seen.
Frequently asked questions
Will it give me dangerous commands?⌄
It can return history-rewriting or destructive commands like reset --hard or push --force when your request implies them. Always read the explanation, and commit or stash first so you have a recovery point before running anything risky.
Do I need to install anything to use the output?⌄
You just need git installed locally to run the commands. The tool itself runs in your browser and only generates the command and explanation.
How specific should my description be?⌄
Very — mention the branch and file names, and whether your commit has already been pushed. 'Undo last local commit, keep changes' yields a precise command, while a vague request gives a generic one.
Is the git command generator free?⌄
Yes, it's free with no signup. Describe your goal and get the command back instantly.
Can it help me recover work I think I lost?⌄
Often, yes — describe what happened (for example, 'I hard reset and lost a commit') and it can suggest reflog-based recovery commands. Act quickly, since git eventually garbage-collects unreachable commits.