Git Command Generator
Build complex git commands visually — fill in parameters and copy.
Create & switch to branch
Create a new branch and switch to it
Delete local branch
Delete a local branch (force optional)
Delete remote branch
Delete a branch from the remote
Rename branch
Rename the current branch
List all branches
List local and remote branches
Amend last commit
Modify the last commit message
Commit with message
Stage all and commit
Squash last N commits
Squash recent commits into one
Cherry-pick commit
Apply a specific commit to current branch
Undo last commit (keep changes)
Undo commit but keep files staged
Undo last commit (unstage)
Undo commit and unstage files
Discard all local changes
Reset to last commit (destructive)
Revert a commit
Create a new commit that undoes changes
Unstage a file
Remove file from staging area
Add remote
Add a new remote repository
Push with upstream
Push and set upstream tracking
Force push (safe)
Force push with lease (safer)
Fetch and prune
Fetch remote and clean stale refs
Stash with message
Stash changes with a description
Apply specific stash
Apply a specific stash entry
List stashes
Show all stash entries
Pop stash
Apply and remove the latest stash
Pretty log
One-line log with graph
Log by author
Show commits by a specific author
Diff between branches
Show commits in branch A not in B
Search commit messages
Find commits by message content
Set user name
Set git username (global)
Set user email
Set git email (global)
Set default branch
Set default branch name for new repos
Git Command Generator — What It Does
Browse git commands organized by category, fill in the required parameters through a simple form, and copy the exact command ready to paste into your terminal. Covers branches, commits, undo operations, stash, remotes, log, and configuration — no more hunting through man pages for the right flags.
Command Categories
- Branch — Create, delete, rename, and switch branches
- Commit — Amend, squash, cherry-pick, fixup commits
- Undo — Reset (soft/mixed/hard), revert, restore, unstage
- Remote — Push, fetch, pull, force-push with lease
- Stash — Save, list, apply, pop, and drop stashes
- Log — Pretty-print history, search commits, diff between refs
- Config — Set global username, email, editor, and aliases
Essential Git Commands
git log --oneline --graph --all— Visual branch historygit diff main...feature— Changes on feature since branching from maingit push --force-with-lease— Safer force push (fails if remote changed)git commit --amend --no-edit— Add staged changes to the last commitgit rebase -i HEAD~3— Interactively squash or reorder last 3 commits
Common Mistakes to Avoid
- git reset --hard on shared branches — Destructively discards commits; use git revert instead to preserve history.
- Rebasing public commits — Rewriting already-pushed commits forces teammates to reset their local copies.
- Force pushing without --force-with-lease — A plain force push can silently overwrite commits made by others since your last fetch.
Frequently Asked Questions
- How do I undo the last git commit without losing my changes?
- Use git reset --soft HEAD~1. The --soft flag moves the HEAD pointer back one commit but leaves your changes staged in the index. If you want changes unstaged but still in your working directory, use --mixed (the default). Use --hard only if you want to discard all changes completely.
- What is the difference between git merge and git rebase?
- git merge combines two branches and creates a merge commit, preserving the full history of both branches. git rebase replays your commits on top of another branch, producing a cleaner linear history. Rebase rewrites commit hashes, so never rebase commits that have already been pushed to a shared remote.
- How do I delete a remote branch in Git?
- Use git push origin --delete branch-name. You can also use the older syntax git push origin :branch-name. To delete the local tracking reference after that, run git fetch --prune or git branch -d branch-name for the local copy.
- What does git stash do and when should I use it?
- git stash saves your uncommitted changes (both staged and unstaged) to a temporary stack and reverts your working directory to the last commit. Use it when you need to quickly switch branches or pull updates without committing half-finished work. Restore with git stash pop (and remove from stack) or git stash apply (keep on stack).
- How do I find which commit introduced a bug?
- Use git bisect. Run git bisect start, then git bisect bad (current commit is broken) and git bisect good <known-good-commit>. Git will binary-search through history, checking out commits for you to test. Mark each as good or bad until Git identifies the first bad commit.