GALAXY OF TOOLS

DEV SECTOR

Git Command Builder

Pick what you want to do (new branch, undo a commit, delete a remote branch) and get the exact git command, explained.

Branch names are checked against Git’s ref-name rules. Quotes are added for you where needed (bash, zsh, PowerShell and cmd accept these forms).

Create a new branch and switch to it

git switch -c feature/login
  1. git switch -c feature/login - Creates the branch at your current commit and moves you onto it.
    • -c create the branch

Older equivalent that works on every Git version: git checkout -b feature/login

Official reference: git-scm.com/docs/git-switch

Git commands cheat sheet

TaskCommandRiskBuilder
Start a new repositorygit init -b feature/loginSafe
Clone a repositorygit clone https://github.com/your-name/your-repo.gitSafe
Set your name and emailgit config --global user.name "Your Name"
git config --global user.email you@example.com
Safe
See what changedgit statusSafe
Stage files for the next commitgit add src/app.jsSafe
Commit staged changesgit commit -m "Fix login redirect"Safe
Commit and pushgit add -A
git commit -m "Fix login redirect"
git push
Safe
Change the last commitgit commit --amend -m "Fix login redirect"Caution
Compare changesgit diffSafe
View commit historygit log --oneline --graph --decorate -n 1Safe
Show one commitgit show a1b2c3dSafe
Create a new branch and switch to itgit switch -c feature/loginSafe
Switch to an existing branchgit switch feature/loginSafe
List branchesgit branchSafe
Rename a branchgit branch -m old-name new-nameSafe
Delete a local branchgit branch -d feature/loginSafe
Delete a remote branchgit push origin --delete feature/login
git fetch origin --prune
Caution
Push a new branch and track itgit push -u origin feature/loginSafe
Merge a branch into the current onegit merge feature/login
git merge --abort
Safe
Rebase onto another branchgit rebase main
git rebase --abort
Caution
Copy one commit to this branchgit cherry-pick a1b2c3dSafe
Add or change a remotegit remote add origin https://github.com/your-name/your-repo.git
git remote -v
Safe
Download changes without merginggit fetch --all --pruneSafe
Pull the latest changesgit pullSafe
Push your commitsgit push origin feature/loginSafe
Force push after rewriting historygit push --force-with-lease origin feature/loginCaution
Unstage a filegit restore --staged src/app.jsSafe
Discard changes to a filegit restore src/app.jsDestructive
Undo the last commit, keep the changesgit reset --soft HEAD~1Caution
Throw away the last commits and all changesgit reset --hard HEAD~1Destructive
Undo a commit safely with a new commitgit revert a1b2c3dSafe
Delete untracked files and foldersgit clean -fdDestructive
Stash your uncommitted workgit stash push -u -m "Fix login redirect"
git stash pop
git stash list
Safe
Restore a file from an older commitgit restore --source=a1b2c3d -- src/app.jsCaution
Recover a lost commit or branchgit reflog
git switch -c rescue HEAD@{1}
Safe
Stop tracking a file but keep it on diskgit rm --cached src/app.jsSafe
Rename or move a filegit mv old/name.js new/name.jsSafe
Create and push a taggit tag -a v1.0.0 -m "Fix login redirect"
git push origin v1.0.0
Safe
Delete a taggit tag -d v1.0.0
git push origin --delete v1.0.0
Caution
See who last changed each linegit blame src/app.jsSafe
Find commits that added or removed textgit log -S"loginRedirect" --onelineSafe

Commands run only on your machine, never here. Based on the Git documentation at git-scm.com/docs.

Runs entirely in your browser. Nothing you enter or upload is sent to a server.

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

  1. Pick a task from What do you want to do?. Tasks are grouped: start, save changes, branches, remotes, undo and recover, tags and history.
  2. Fill in the fields that appear (branch, message, commit hash, file path). Invalid branch names and numbers are flagged.
  3. Tick any options, such as a force delete or a rebase on pull. The command and explanation update immediately.
  4. Read the warning box if there is one. Prefer a listed safer option when you are not sure.
  5. 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.

CommandWhat can be lostSafer first step
git reset --hard HEAD~1Uncommitted changes and the dropped commitgit stash or git branch backup; or git revert
git clean -fdUntracked files and foldersgit clean -nd (dry run) or git stash -u
git push --forceOther people’s commits on the remotegit push --force-with-lease
git restore FILEUncommitted edits to the filegit stash push -- FILE
git branch -DCommits found only on that branchgit 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.

You might also need