Git command generator

Search or browse everyday git tasks grouped by setup, commit, branch, undo, remote, stash and inspect. Fill in the branch, file or message and copy the command. Commands that can lose work carry a warning.

Create a branch and switch to it

git switch -c <branch>

Creates a branch at the current commit and moves HEAD to it. On older git use git checkout -b <branch>.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Search by words such as “undo”, “branch” or “stash”, or choose a category.
  2. Click a task in the list.
  3. Fill in the boxes for the branch, file, commit or message. Until a box is filled, the placeholder stays in the command.
  4. Copy the command and run it in your repository.

About the commands

The list covers daily work rather than every git feature. Commands that can throw away work or rewrite history show a warning. As a rule of thumb, anything with --hard, clean, --force or rebase deserves a second look before you press Enter.

Example

Task “Create a branch and switch to it” with the branch name fix-login:

git switch -c fix-login

Tips

Run git status before an undo command so you know what is staged and what is not. For commands you are unsure about, git clean -nd and git stash give you a safe way to look or to set work aside first.

Frequently asked questions

What is the difference between git reset --soft, --mixed and --hard?

All three move the branch to another commit. --soft leaves your changes staged, the default --mixed leaves them in your files but unstaged, and --hard also resets your files so the changes are lost. Only --hard can destroy uncommitted work.

How do I undo a commit that I already pushed?

Use git revert with the commit id. It adds a new commit that reverses the old one, so nobody else's history is rewritten. Resetting and force-pushing also works but forces everyone who has pulled the branch to fix their copy.

Why do the commands use git switch and git restore?

They were added in git 2.23 to split the many jobs of git checkout into two clearer commands. The old git checkout commands still work. If your git is older, git checkout -b <branch> replaces git switch -c <branch>.

What if I reset or delete something by mistake?

Run git reflog. It lists every place HEAD has been, including commits no branch points to, for a limited time. Create a branch at the commit you want with git switch -c <branch> <commit>. Uncommitted changes that were discarded are not in the reflog.

Does this tool run the commands?

No. It only shows the text to copy. Nothing is sent anywhere and no repository is touched.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.