Skip to content
~/Git Command Builder
$

Git Command Builder

Build Git commands visually β€” pick what you want to do, fill in the details, and get the exact command with a plain-English explanation.

Generated Command
git init

Initializes a new Git repository in the specified directory.

Options

How does this Git command builder work?

Pick one of eight categories β€” setup, basic, branching, remote, stash, history, undo, or advanced β€” choose an operation, and fill in details like branch names or commit references. The exact command updates live with a plain-English explanation of what it will do, so you can copy it with confidence instead of pattern-matching from old shell history. Everything runs in your browser; no repository data is involved or uploaded.

How do I undo my last git commit?

It depends what you want to keep. git reset --soft HEAD~1 removes the commit but leaves your changes staged β€” ideal for fixing a bad commit message or splitting a commit. git reset --mixed HEAD~1 (the default) unstages the changes too. git reset --hard HEAD~1 throws the changes away entirely, so treat it with care. If you only need to edit the message or add a forgotten file, git commit --amend is simpler β€” but never amend commits you have already pushed.

What is the difference between git merge and git rebase?

Both integrate changes from one branch into another. Merge creates a new merge commit and preserves history exactly as it happened; rebase replays your commits on top of the target branch, producing a linear history with no merge bubbles. The golden rule: never rebase commits that others have already pulled, because rewriting shared history forces everyone downstream to recover. Rebase your local feature branches; merge into shared ones.

How do I recover a deleted branch or lost commit?

Almost nothing in Git is truly gone. git reflog shows every position HEAD has occupied β€” including commits orphaned by reset --hard or a deleted branch. Find the entry just before the mistake, then git checkout -b rescue <hash> to resurrect it. Reflog entries are kept for 90 days by default, so act before garbage collection. This is the single most useful recovery command in Git and the first thing to reach for after a scary mistake.

What is the difference between git fetch and git pull?

git fetch downloads new commits from the remote and updates your remote-tracking branches (like origin/main) without touching your working files β€” it is always safe. git pull is fetch plus an immediate merge (or rebase, with git pull --rebase) into your current branch. When you want to review incoming changes first, fetch, inspect with git log main..origin/main, then merge deliberately. Most pull surprises are really unreviewed merges.

When should I use git stash?

Stash shelves uncommitted changes so you can switch branches or pull with a clean working tree, then restore them later. git stash push -m 'wip: form validation' gives the entry a searchable name, and -u includes untracked files, which plain stash silently skips β€” a common source of confusion. Prefer git stash apply over pop while resolving conflicts: pop deletes the stash even if the apply half-fails, while apply keeps a safety copy.

Is it ever safe to force push?

Plain git push --force overwrites the remote branch unconditionally β€” if a teammate pushed in the meantime, their commits vanish. Use git push --force-with-lease instead: it refuses to push if the remote has moved since you last fetched, turning a destructive overwrite into a checked one. Force pushing is legitimate after rebasing your own feature branch; on shared branches like main it should be blocked by branch protection entirely.