A Git command builder and cheat sheet in one page
Most Git questions look the same: how do I create a new branch, undo the last commit, delete a remote branch or push my work? This Git command builder turns the task into the exact command. Choose what you want to do, type the branch name, message or commit, and the command appears with a line-by-line explanation of what it does and what every flag means.
Some commands lose work: git reset --hard, git clean -fd, git push --force and discarding a file. They are labelled, and each comes with safer alternatives such as --force-with-lease, a dry run with git clean -nd or a stash. The cheat sheet at the bottom lists every task, can be filtered, and opens any row in the builder. Nothing runs here; you copy the command into your own terminal.
How to use the Git Command Builder
- Pick a task from What do you want to do?. Tasks are grouped: start, save changes, branches, remotes, undo and recover, tags and history.
- Fill in the fields that appear (branch, message, commit hash, file path). Invalid branch names and numbers are flagged.
- Tick any options, such as a force delete or a rebase on pull. The command and explanation update immediately.
- Read the warning box if there is one. Prefer a listed safer option when you are not sure.
- Press Copy command and paste it into your terminal, or search the cheat sheet and press Open.
Git Command Builder features
Exact commands, explained
Every step has a plain explanation and a list of the flags used, taken from the behaviour described in the Git manual.
Modern and compatible
Uses git switch and git restore (Git 2.23+) and mentions the older checkout forms where they are common.
Risk labels
Safe, Caution and Destructive tags in the cheat sheet, and a coloured warning with recovery options in the builder.
Quoting handled
Messages with quotes, spaces or apostrophes are quoted correctly, so the command works when pasted.
Links to the official docs
Each result links to the matching page on git-scm.com/docs.
Which commands are destructive?
These commands can permanently delete work. The table shows why and what to do first.
| Command | What can be lost | Safer first step |
|---|---|---|
git reset --hard HEAD~1 | Uncommitted changes and the dropped commit | git stash or git branch backup; or git revert |
git clean -fd | Untracked files and folders | git clean -nd (dry run) or git stash -u |
git push --force | Other people’s commits on the remote | git push --force-with-lease |
git restore FILE | Uncommitted edits to the file | git stash push -- FILE |
git branch -D | Commits found only on that branch | git branch -d (refuses unmerged work) |
Undo without panic
If you reset or deleted something by mistake, run git reflog. It lists where HEAD has been, including commits no branch points to any more, usually for at least 30 days. Create a branch at the entry you want with git switch -c rescue <hash>. Uncommitted changes and untracked files that were erased are not in the reflog, which is why the builder suggests a stash or dry run first.
Pull, merge or rebase?
git pull is a fetch plus a merge; git pull --rebase replays your local commits on top, giving a straight history. Rebasing rewrites commits, so avoid it on branches others use. For ignoring files see the .gitignore generator, and for the file you add first in a new project the licence generator.
Git Command Builder FAQ
What is the git command to create a new branch?
Use git switch -c feature/name. It creates the branch and moves you onto it. On older Git versions use git checkout -b feature/name.
What is the git command to delete a branch?
git branch -d name deletes a merged local branch, -D forces it, and git push origin --delete name removes it from the remote.Which git commands commit and push?
git add -A, then git commit -m "message", then git push. The first push of a new branch needs git push -u origin branch.How do I undo the last commit?
If it is not pushed, git reset --soft HEAD~1 keeps your changes staged. If it is pushed, use git revert HEAD, which adds a new commit instead of rewriting history.
What is the difference between --force and --force-with-lease?
--force always overwrites the remote branch. --force-with-lease overwrites only if the remote is still where you last saw it, so it will not erase a teammate’s new commits.Does this tool run Git commands?
No. It only builds text. You run the commands yourself, in your own repository.