Reference
A reference page. Catalase has a visual git panel with staging, diffs and AI-written commit messages — see the features.
How it works
The commands, by task
Everyday work
| Command | What it does |
|---|---|
git status | What is staged, changed and untracked |
git add -p | Stage changes hunk by hunk — the best habit on this page |
git commit -m "msg" | Commit what is staged |
git commit --amend | Rewrite the last commit. Never after pushing to a shared branch |
git log --oneline --graph --all | Readable history with branch topology |
git diff / --staged | Unstaged changes / staged changes |
git switch -c name | Create and move to a branch (clearer than checkout -b) |
git restore file | Discard unstaged changes to a file |
git restore --staged file | Unstage, keeping the edit |
Undoing things
| Command | What it does | Safe on a shared branch? |
|---|---|---|
git revert <sha> | New commit undoing an old one | Yes |
git reset --soft HEAD~1 | Undo the commit, keep changes staged | No |
git reset --mixed HEAD~1 | Undo the commit, keep changes unstaged | No |
git reset --hard HEAD~1 | Undo the commit and discard the changes | No — destructive |
git reflog | Every HEAD position, including "lost" commits | Yes |
git stash / git stash pop | Shelve and restore work in progress | Yes |
Branches and remotes
| Command | What it does |
|---|---|
git fetch --prune | Update remote refs and drop deleted ones |
git pull --rebase | Update your branch without a merge commit |
git merge --no-ff name | Merge, always creating a merge commit |
git rebase main | Replay your commits on top of main |
git push -u origin name | Push and set upstream tracking |
git push --force-with-lease | Force push that refuses if someone else pushed first |
git cherry-pick <sha> | Apply one commit from elsewhere |
Finding things
| Command | What it does |
|---|---|
git blame file | Who last changed each line |
git log -S"text" | Commits that added or removed that text |
git log -- file | History of one file |
git bisect start | Binary search for the commit that broke something |
git grep "text" | Search the working tree, respecting .gitignore |
Almost nothing is really lost
The single most useful thing to know: git reflog records every position HEAD has held, including commits that are no longer reachable from any branch. A bad reset --hard, a botched rebase, a deleted branch — all recoverable.
git reflog # find the sha you want
git reset --hard <sha> # or: git branch recovered <sha>Unreachable commits survive until garbage collection, which by default leaves them for 90 days. The exception, and it is the important one: uncommitted changes are not in Git at all. git reset --hard or git checkout -- destroys them with no recovery. Commit or stash before anything drastic.
Rewriting history, and when not to
commit --amend, rebase and reset all rewrite history: they replace commits with new ones that have different hashes. On your own unpushed work this is good practice — it produces a history worth reading.
On a branch others have pulled, it forces everyone else to reconcile a divergent history, and someone will resolve it wrongly. The rule: rewrite freely before you push, never after, unless the branch is yours alone and you have said so.
When you must force push, use --force-with-lease rather than --force. It refuses if someone else has pushed since you last fetched, which turns silently destroying a colleague’s work into an error message.
Merge or rebase
Both integrate one branch into another; they differ in the history they leave.
- Merge preserves exactly what happened, at the cost of merge commits. Honest, and sometimes noisy.
- Rebase replays your commits on top of the target, giving a linear history. Cleaner to read, but it rewrites your commits — so rebase your own feature branch, not a shared one.
A common convention: rebase your feature branch onto main while you work, then merge it with --no-ff so the feature stays visible as a unit.
Writing commit messages worth reading
A short imperative summary under about 50 characters (“Fix off-by-one in pagination”, not “Fixed” or “changes”), a blank line, then the why — the diff already shows the what.
Conventional Commits adds a machine-readable prefix: feat:, fix:, docs:, refactor:, test:, chore:, with ! or a BREAKING CHANGE: footer for incompatible changes. Tooling can then derive changelogs and version bumps automatically.
What people use it for
- Undoing a commit without losing the work in it.
- Recovering a branch you deleted or reset away.
- Finding which commit introduced a bug with
bisectorlog -S. - Cleaning up a messy branch before opening a pull request.
- Checking whether a command is safe on a branch other people share.
Nothing is uploaded. This tool runs entirely in JavaScript in your browser. Your input is never sent to a server, never logged and never stored, and no account is required. Once the page has loaded you can go offline and it still works — open your browser's network tab and watch if you'd like to confirm it.
Frequently asked questions
How do I undo my last commit?
Depends what you want kept. git reset --soft HEAD~1 undoes the commit and keeps changes staged; --mixed keeps them unstaged; --hard discards them entirely. On a branch others have pulled, use git revert instead, which records a new commit that undoes the old one.
What is the difference between reset and revert?
reset moves the branch pointer and rewrites history, which is unsafe on a shared branch. revert creates a new commit that undoes an earlier one, leaving history intact, which is always safe to push.
Can I recover a commit I reset away?
Almost always. git reflog lists every position HEAD has held, including unreachable commits, and they survive for 90 days by default. Uncommitted changes are the exception: they were never in Git and cannot be recovered.
Should I merge or rebase?
Rebase your own feature branch to keep history linear and readable; merge to integrate it, ideally with --no-ff so the feature stays visible as a unit. Never rebase a branch other people have pulled.
Why use --force-with-lease instead of --force?
It refuses the push if someone else has pushed since you last fetched. Plain --force overwrites their work silently; --force-with-lease turns that into an error you can act on.
Tools that run where your code is
This page does its work in your browser because sending your data to a server to process it is a bad default. Catalase applies the same idea to AI coding: a free, open-source code editor that runs language models on your own machine through Ollama, with no account and no telemetry. Cloud models are there when you choose one, not by default.
Related tools
- Diff checker — Compare two versions of a file.
- Regex cheat sheet — Pattern syntax reference.
- Markdown cheat sheet — For writing READMEs and PR descriptions.