Building command...
Select a category, choose a command, configure options, then click Build Command →
Why a Git Command Builder?
Every week, millions of developers search phrases like "how to git rebase", "git stash command", or "git push force safe". The answer is always the same page of static documentation — flags listed without context, no indication of which ones to combine, and no plain-English explanation of what the assembled command will actually do.
This builder solves that. Choose your action from the 8 categories, toggle the options you need, and the tool assembles the command in the correct order — including quoting string values, using short forms where idiomatic, and flagging destructive combinations before you run them.
The 8 Git Workflow Categories
Branching & Merging
Create, switch, and delete branches. Merge with --no-ff to preserve history, or rebase with -i to squash commits before merging into main.
History & Inspection
Combine git log --oneline --graph --all to see your full branch topology. Use git blame -w to track the origin of every line ignoring whitespace.
Staging & Committing
git add -p lets you stage individual hunks rather than whole files — essential for keeping commits atomic and review-friendly.
Remote Operations
Always prefer --force-with-lease over --force when pushing rewrites — it fails safely if a teammate has pushed new commits since your last fetch.
Stash
Use git stash push -u -m "label" to shelve untracked files with a descriptive name. Use git stash apply stash@{1} to restore a specific entry without removing it from the list.
Tags
Annotated tags (git tag -a v1.0.0 -m "message") store the tagger name, email, and date — preferred for release versioning over lightweight tags.
Advanced
git cherry-pick applies a specific commit to another branch — ideal for backporting bug fixes without merging an entire feature branch. git bisect finds the exact commit that introduced a regression via binary search.
Config & Maintenance
Always run git clean -n for a dry run before git clean -f. Untracked file deletion is permanent — there is no recycle bin in Git.
Destructive Commands Explained
| Command | Risk | Safe alternative |
|---|---|---|
| git reset --hard | Discards all uncommitted changes permanently | git stash push first |
| git push --force | Overwrites remote branch, erases teammates' work | --force-with-lease |
| git clean -f | Permanently deletes untracked files | git clean -n first |
| git branch -D | Deletes branch even with unmerged commits | git branch -d (safe) |
| git rebase -i | Rewrites history — safe on private branches only | Only on unshared branches |
The builder shows an amber warning banner whenever you enable a destructive flag.
Git Branching Strategies
Trunk-Based Development
All developers commit directly to main (or merge short-lived branches within 1–2 days). Key commands: git switch -c, git merge --squash, git push --force-with-lease after interactive rebase.
GitFlow
Long-lived develop and release branches with feature branches off develop. Key commands: git merge --no-ff to preserve merge commits at every integration point, git tag -a for release tags, git cherry-pick to backport fixes to older release branches.
One Flow
A simplified GitFlow with a single main branch and feature branches that rebase before merging. Key commands: git rebase -i main to clean up commits, then git merge --ff-only to integrate.
Frequently Asked Questions
What is the difference between git rebase and git merge?
Both commands integrate changes from one branch into another. git merge creates a new merge commit that has two parents, preserving the exact history of both branches. git rebase replays your commits on top of the target branch, producing a linear history with no merge commit. Use merge for shared branches to avoid rewriting published history; use rebase for private feature branches to keep the log clean before a PR.
When should I use --force-with-lease instead of --force?
Always prefer --force-with-lease. It checks that the remote branch tip matches what you last fetched — if a teammate pushed new commits since your last fetch, the push will be rejected safely instead of overwriting their work. Plain --force always overwrites, regardless of remote state, and should only be used in single-developer scenarios where you are certain of the remote state.
How do I undo the last commit without losing my changes?
Use git reset --soft HEAD~1. This moves the branch pointer back one commit but leaves all the changes staged, so you can re-commit with a corrected message or split into multiple commits. Use --mixed (the default) to unstage the changes, or --hard only if you want to permanently discard everything.
What does git stash actually save?
By default, git stash push saves tracked modified files (both staged and unstaged). It does NOT save untracked files or files ignored by .gitignore. Add -u to include untracked files. Each stash entry is stored as a special commit internally — you can recover entries for a while even after git stash drop by using git reflog.
How do I delete a remote branch?
Run git push origin --delete branch-name. This deletes the branch on the remote. To also remove the local remote-tracking reference, run git fetch --prune afterward. To delete the local branch as well, use git branch -d branch-name (or -D to force-delete if unmerged).
Related Developer Tools
Docker Compose Validator
Validate docker-compose.yml files: services, ports, depends_on cycles, and volumes.
RegEx Tester
Test regular expressions with match highlighting, capture groups, and replacement previews.
Cron Job Parser
Parse cron expressions into plain English and see next execution times instantly.