Search 50 Git recipes in plain English. Undo commits, fix mistakes, branch, rebase, stash and recover lost work, with pitfalls and copy-ready commands.
Most Git problems are not knowledge problems — they are recall problems. You know there is a command that un-stages a file without losing the edit, you just cannot remember whether it is git reset, git restore, or git checkout. This reference is built for that moment. Type what you are trying to do in ordinary words — “undo my last commit”, “delete a remote branch”, “save my work without committing” — and the matching recipes surface with a runnable command, an explanation of what it changes, and the pitfalls that come with it.
The library covers 50 task-focused entries across nine categories, each written as a recipe rather than a man page. Every entry carries a skill level (Beginner, Intermediate, Advanced), one or more copy-ready commands, a “when to use this” list, and where relevant a set of pitfalls. Several commands include live parameters — a slider for how many commits to go back, a field for a file path — so the command you copy already has your values substituted in.
| Category | Entries | Typical questions it answers |
|---|---|---|
| Fix Mistakes | 10 | Undo a commit, amend a message, un-stage a file, discard local edits |
| History & Inspection | 10 | Find who changed a line, search history for a string, compare branches |
| Branching & Merging | 7 | Rebase vs merge, cherry-pick, squash, resolve conflicts, rename a branch |
| Workspace & Stash | 6 | Stash and restore work, clean untracked files, switch context mid-task |
| Collaboration | 4 | Push, pull, track remotes, delete a remote branch |
| Setup & Basics | 4 | Configure identity, clone, initialise, set the default branch |
| Scaling & Performance | 4 | Shallow clones, sparse checkout, partial clone, large repositories |
| Recovery & Safety | 3 | Recover a lost commit with the reflog, rescue a detached HEAD |
| Commits | 2 | Stage selectively, write commits that survive review |
You can filter by category, by skill level, or both, and searching narrows within whatever filter is active. Every command block has a copy button, so nothing needs to be retyped.
HEAD~3.--force or reset --hard. They are there because those commands destroy work in ways the message output does not warn about.“Undo” is the single most searched Git topic, and it maps to at least five different commands depending on what you want undone and whether it has been shared. This is the mental model the reference is organised around:
| Command | What it changes | Safe on pushed commits? |
|---|---|---|
git restore <file> | Discards uncommitted edits in the working tree | N/A — local only, but the edits are gone |
git restore --staged <file> | Un-stages a file, edits untouched | Yes — nothing is lost |
git commit --amend | Replaces the most recent commit | No — rewrites history |
git reset --soft HEAD~1 | Removes the commit, keeps changes staged | No — rewrites history |
git reset --hard HEAD~1 | Removes the commit and the changes | No — and destroys uncommitted work |
git revert <sha> | Adds a new commit that undoes an old one | Yes — history is append-only |
The dividing line is whether the commit has left your machine. Anything that rewrites history is fine on a local branch and hostile on a shared one, because every collaborator’s copy now disagrees with the remote. On a branch other people have pulled, git revert is the correct tool even though it leaves a visible “Revert…” commit in the log.
Git records every movement of HEAD in the reflog, including commits that a hard reset or a botched rebase appears to have destroyed. Those objects stay in the repository until garbage collection runs, typically 90 days later. So the recovery recipe is:
git reflog to list recent HEAD positions, find the entry from just before the mistake, then git reset --hard HEAD@{5} or git checkout -b rescue HEAD@{5} to get back to it. Creating a branch is the safer of the two, because it does not move your current branch until you have confirmed you found the right commit.
The reflog is local and per-clone. It will not recover work you never committed, and it does not exist on a fresh clone. That is the argument for committing early and often even on scratch branches — a commit is recoverable, an uncommitted working tree is not.
Both integrate one branch into another; they differ in what the history looks like afterwards. git merge creates a merge commit with two parents, preserving the fact that the work happened in parallel. git rebase replays your commits on top of the target branch, producing a straight line as if you had started from the latest code.
The practical rule most teams settle on: rebase your own unpushed feature branch onto main to keep it current, then merge the finished branch into main. Never rebase a branch that others have based work on. If you do need to push a rebased branch, git push --force-with-lease is strictly better than --force — it refuses the push if the remote has commits you have not seen, which is exactly the case where a force push destroys a colleague’s work. If you want to see the shape a given strategy produces before committing to it, the Git branch visualizer draws the resulting commit graph.
git reset --soft HEAD~1 removes the commit and leaves everything staged, ready to re-commit. Use --mixed (the default) instead if you want the changes un-staged but still in the working tree. Only do this if the commit has not been pushed.
git restore works on files in the working tree or index and does not touch commits. git reset moves your branch pointer backwards, rewriting history. git revert creates a new commit that reverses an old one, leaving history intact — the only one of the three that is safe on a shared branch.
Run git reflog, locate the HEAD@{n} entry from before the reset, and check it out into a new branch with git checkout -b rescue HEAD@{n}. This works for roughly 90 days, until garbage collection prunes unreachable objects.
git push origin --delete branch-name. Deleting your local copy with git branch -d branch-name does not affect the remote, and vice versa — they are separate operations.
Each entry carries a list of intent phrases. Your query is tokenised, stop words are removed, and it is scored against those phrases; matches above the threshold are surfaced with the phrase that matched, so you can see why a result appeared. It is lightweight keyword matching running in your browser, not a language model.
Prefer --force-with-lease, which aborts if the remote has moved since your last fetch. Plain --force overwrites the remote unconditionally and is the standard way teams lose commits. Neither belongs anywhere near a shared main branch.
Yes. Git’s commands are identical across platforms. The only differences are shell quoting rules — PowerShell handles quotes and globs differently from bash — and line-ending configuration, which is what core.autocrlf controls.
Yes, free and unlimited with no account. If you are setting up a new repository, our .gitignore generator and semantic version calculator pair well with it.
Git is the most widely used distributed version control system, tracking changes to source code across software development projects. With over 150 commands and thousands of flags, Git's command-line interface is powerful but complex. Even experienced developers regularly look up less common commands, flag combinations, and workflows.
This tool provides a searchable reference for Git commands organized by workflow — from basic operations to advanced rebasing, bisecting, and repository maintenance.
| Command | Purpose | Example |
|---|---|---|
| git status | Show working tree status | git status -sb |
| git add | Stage changes | git add -p (interactive staging) |
| git commit | Record changes | git commit -m "Fix login timeout" |
| git pull | Fetch and merge remote changes | git pull --rebase origin main |
| git push | Upload local commits | git push origin feature-branch |
| git diff | Show unstaged changes | git diff --cached (staged changes) |
| git log | View commit history | git log --oneline --graph |
| git stash | Temporarily shelve changes | git stash push -m "WIP login fix" |
| Command | Purpose | Example |
|---|---|---|
| git branch | List, create, delete branches | git branch -d feature-branch |
| git checkout | Switch branches or restore files | git checkout -b new-feature |
| git switch | Switch branches (modern) | git switch -c new-feature |
| git merge | Combine branch histories | git merge --no-ff feature-branch |
| git rebase | Reapply commits on new base | git rebase main |
| git cherry-pick | Apply specific commits | git cherry-pick abc1234 |
The reference is organized by practical tasks and categories including Setup and Basics, Commits, Fix Mistakes, Branching and Merging, Collaboration, History and Inspection, Workspace and Stash, Recovery and Safety, and Scaling and Performance. Each command guide includes when to use it, pro tips, and common pitfalls to avoid.
Yes, the tool includes natural language understanding. You can type questions like "how do I undo my last commit" or "revert changes" and it will interpret your intent and show relevant Git commands. The search interprets your question and displays matching command guides ranked by relevance.
Commands are tagged as Beginner, Intermediate, or Advanced. Beginners can focus on essential commands like git add, commit, and push. Intermediate users can explore branching, merging, and stashing. Advanced users can find commands for rebasing, cherry-picking, and repository maintenance.
Each command example has a Copy button that copies the exact command to your clipboard. Many commands also include adjustable parameters with sliders or text inputs, so you can customize values like commit counts or file paths before copying. The command updates in real-time as you adjust parameters.
Common Pitfalls highlight dangerous operations or frequently made mistakes for each command. These warnings help you avoid accidentally losing work, corrupting your repository, or creating problems for your team. They are especially important for destructive commands like force push or hard reset.
Yes, many command guides include an Alternatives section showing different ways to accomplish the same task. This helps you choose the right approach based on your specific situation. For example, undoing changes might show options for both local and already-pushed commits.
Yes, each command guide includes a Related section with links to other relevant commands. Clicking a related command jumps directly to that guide. This helps you discover connected workflows, like going from staging to committing to pushing, or from creating a branch to merging it.