Search 50 Git recipes in plain English. Undo commits, fix mistakes, branch, rebase, stash and recover lost work, with pitfalls and copy-ready commands.
By Inventive HQ
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.
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.