Git Command Generator

Search or browse 41 everyday Git tasks, click one to see its command at once, and fill in your branch, file, or commit to update it. You get the command, what each part does, a commit graph, a safety rating, and how to undo it.

Popular tasks

Your names and values

This command needs no names.

About this Git command generator

Git can do almost anything, but the command for a given job is often hard to remember and easy to get dangerously wrong: reset --soft versus --hard, revert versus reset, push --force versus --force-with-lease. This generator starts from what you want to do, in plain words, and gives you the exact command with your own branch, file, and commit names filled in. Each part of the command is explained, a small before-and-after commit graph shows what happens to your history, a color-coded rating warns when a command can lose work or rewrite shared history, and an undo hint tells you how to get back, usually through git reflog. It covers 41 everyday tasks across branches, commits, undo, stash, merge, rebase, cherry-pick, remotes, tags, inspection, and setup.

How to find a Git command

  1. Find your task. Search in plain words, such as undo commit, or filter by category, then click a task to see its command.
  2. Fill in your names. Enter your branch, file, commit hash, or message in the fields that appear; the command updates as you type.
  3. Copy and run it. Copy the command, read the explanation and safety rating, and note the undo hint before running it.

Frequently asked questions

What is the difference between reset and revert?

reset moves your branch back and rewrites history, which is fine for local commits. revert adds a new commit that undoes an old one, which is safe for commits others already have.

Why use --force-with-lease instead of --force?

It refuses to overwrite the remote branch if someone pushed new commits since your last fetch, so you cannot silently delete a teammate’s work.

Should I use git switch or git checkout?

git switch (and git restore for files) arrived in Git 2.23 to split checkout’s many jobs. They are clearer; checkout still works if you prefer it.

Can I recover a commit after reset --hard?

Usually, yes. git reflog lists recent positions of HEAD; find the commit and run git reset --hard <hash>. Uncommitted changes, however, cannot be recovered.

What do the safety colors mean?

Green commands lose nothing. Amber ones rewrite local history or change shared state and need care. Red ones can permanently delete work or overwrite others’ commits.