Utilo

Git Command Generator

Find the right git command for common situations — undo a commit, rename a branch, squash, recover lost work, sync a fork — with editable placeholders, plain-language explanations and safety warnings.

What this Git command generator does

Git can do almost anything, but remembering whether you need reset --soft, restore --staged or revert at the moment you need it is another matter. This tool flips the problem around: you describe what you want to do, and it gives you the right commands. It contains around 30 curated scenarios covering undoing mistakes, managing branches, rewriting commits, syncing with remotes, stashing, digging through history and cleaning up. Each scenario comes with editable parameters, a plain-language explanation and, for commands that rewrite history or delete work, a clear warning.

How to use it

  1. Type what you want in the search box, for example "undo last commit" or "rename branch", or browse by category.
  2. Click a scenario to open it.
  3. Fill in the parameters, such as branch names, commit hashes or file paths. The commands update as you type.
  4. Read the explanation and any warning, then copy the commands into your terminal.

Scenarios included

  • Undo: undo the last commit while keeping or discarding changes, unstage a file, discard local edits, revert a pushed commit and recover a deleted branch with the reflog.
  • Branches: create, rename locally and on the remote, delete, move commits made on the wrong branch, rebase onto the latest main.
  • Commits: amend the message, add a forgotten file, squash the last N commits, cherry-pick, abort a conflicted merge, resolve conflicts by taking one side.
  • Remotes: force-push safely with --force-with-lease, sync a fork with upstream, change the remote URL, reset a branch to match the remote.
  • History and cleanup: stash and restore work, find the commit that introduced a bug with bisect, search for when text was added, a compact log graph, stop tracking a file, clean untracked files and tag a release.

Safety tips

  • Before anything destructive, create a backup branch: git branch backup-before-fix.
  • The reflog keeps references to recent commits for about 90 days. Most "lost" work can be recovered with git reflog.
  • Never rewrite history on shared branches like main without coordinating with your team.
  • Prefer --force-with-lease over --force; it refuses to overwrite work you haven't fetched.

Frequently asked questions

Which Git version do the commands target?

Commands use modern syntax (git switch, git restore) available since Git 2.23. Most also work on older versions with checkout equivalents.

Are the explanations available in my language?

Yes. Scenario titles and explanations are translated into all supported languages; the commands themselves stay in Git's English syntax.

Can I suggest a scenario?

Yes, use the contact page. Common real-world problems are added regularly.

Does the tool run Git for me?

No. It only generates text. You stay in control of what runs in your repository.

Yes. All processing happens directly in your browser using JavaScript, Web Workers and Web APIs. Nothing you type, paste or upload is sent to our servers.