How to use the Git Command Generator
- 1. Pick what you want to doUndo, branches, commits, history, files or remotes, 27 tasks in all.
- 2. Fill in the detailsBranch names, file paths, commit hashes or messages, where a task needs them.
- 3. Show commandsCopy the commands, read what each one does, and check the safety note.
Choosing the safe command
Git usually has several ways to do one thing, and the difference is whether the commit has been shared. Commands that rewrite history, such as reset, commit --amend or squashing, are fine on commits you haven't pushed; on shared branches, use revert, which adds a new commit that undoes the old one. Each task here is labelled Safe, Safe on commits you haven't pushed, Take care (it changes the remote) or Destructive (work is lost). The commands use the modern git switch and git restore (Git 2.23 or later) instead of the overloaded checkout. Inputs are checked, so a branch name with spaces or a bad commit hash is refused, and messages are quoted safely. Nothing leaves your browser.
We ran every task's commands in a scratch repository with its own remote, prepared for that situation, and checked the result, for example that the squash produced one commit and that the untracked .env file was kept on disk.
Worked example
To combine the last 3 commits into one with the message Add login page, the tool gives git reset --soft HEAD~3 (step back three commits, keeping all their changes staged) followed by git commit -m 'Add login page', and notes that it's safe only on commits you haven't pushed.
Habits that save you
- Run
git statusbefore and after anything unusual. git reflogremembers where HEAD has been for weeks, so most "lost" commits can be recovered.- Use
--force-with-lease, never plain--force, when you must overwrite a branch.
Frequently asked questions
What's the difference between reset and revert?
reset moves your branch back, rewriting history; revert adds a new commit that undoes the changes, which is safe on shared branches.
I used reset --hard by mistake. Can I get it back?
Usually, yes: run git reflog, find the commit before the reset, and run git reset --hard to that entry.
Is the Git command generator free?
Yes. You can open the Git command generator and change every input and rate without signing up. When you show the commands for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.