Git command generator
Can’t remember how to undo the last commit without losing your changes, delete a remote branch, rename a branch, squash commits or stop tracking a file that is already committed? Choose the task, fill in the names, and the generator writes the commands with values quoted safely for the shell. Tasks that rewrite history or throw work away are clearly marked so you can think twice before running them, and safer alternatives are used where they exist, such as git switch, git restore and push --force-with-lease.
Removes the last commit but keeps its changes staged.
This rewrites history. Fine on your own branch; avoid it on branches others use.
How to use the Git Command Generator
- 1
Choose a task
Grouped by setup, branches, commits, undo, remotes, stash, history, tags and cleanup.
- 2
Fill in the values
Branch names, messages, paths or URLs.
- 3
Copy and run
Read any warning, then run the commands in your repository.
When to use it
- Fix a mistake without searching the web.
- Learn modern Git commands.
- Give teammates safe, copy-ready instructions.
Limits
- Commands are shown, never run. Check them against your situation, especially history rewrites on shared branches.
- Interactive rebases and conflict resolution need you at the terminal.
Privacy
Runs in your browser; nothing is sent.
Frequently asked questions
What is the difference between reset --soft and --hard?
--soft moves the branch back but keeps your changes staged. --hard throws the changes away, which is why it is marked destructive.
Why push --force-with-lease instead of --force?
It refuses to overwrite the remote branch if someone else pushed in the meantime, so you don’t delete their work.
Is it safe to rewrite history?
On your own branch, yes. On a branch others have pulled, rewriting forces everyone to fix their copies; prefer git revert there.
How do I recover a commit I lost?
git reflog lists where HEAD has been. Find the commit hash and create a branch from it.
Why are some values quoted?
Spaces, quotes and $ have special meaning in the shell. Quoting makes sure Git receives exactly what you typed.
Related tools
People also use
- JWT Generator & SignerCreate and sign JSON Web Tokens with HMAC, RSA or ECDSA keys, entirely in your browser.
- Base64 Encoder & DecoderEncode and decode Base64 and Base64url, text or files.
- URL Encoder & DecoderPercent-encode or decode URLs and see their query parameters.
- CSV to JSON ConverterConvert CSV ⇄ JSON with correct quoting, types and nested data.
Last updated November 24, 2026 · How we build and test our tools