Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Cheat sheet · OtherFree

Oh Shit, Git!?!

A single page of Git recovery recipes by Katie Sylor-Miller, organised by the mistake you just made rather than by the command that fixes it. It is for anyone who uses Git daily and occasionally breaks something: committing to the wrong branch, needing to amend a commit, or losing work after a reset. A swear-free version and many translations exist.

Topics
Cost

Free

ohshitgit.com · Sept 2026

Format

Single web page

ohshitgit.com · Sept 2026

Format

Cheat sheet

Topic

Other

Provider

Katie Sylor-Miller

Time needed

Seconds per lookup

Level

All

Access

Free

What it is

A short web page listing common Git disasters in plain English, each followed by the exact commands that get you out of it and a line or two on what they do. The situations include:

  • You did something terribly wrong and want Git's "time machine" (reflog).
  • You committed and immediately realised you needed one more small change.
  • You need to change the message on your last commit.
  • You committed to the main branch when the work should have been on a new branch.
  • You committed to the wrong branch.
  • You ran diff and nothing appeared (because the changes were staged).
  • You need to undo a commit from several commits ago.
  • You need to undo changes to a single file.
  • You give up and want your local branch to match the remote again.

It was written by Katie Sylor-Miller, a frontend engineer, and has been translated into many languages. There is also a swear-free version called Dangit, Git for sharing at work or school, and a paid illustrated zine with Julia Evans that explains the same ground in more depth.

Why organising by mistake works

Most Git references are organised by command, which does not help when you are panicking. You know what went wrong, not that the fix is called reset, revert or cherry-pick. Indexing by the problem solves that chicken-and-egg issue.

The one to understand properly

Reflog. Git almost never truly loses a commit. The reflog records where HEAD has pointed recently, so after a bad reset, rebase or branch deletion you can usually find the old commit and restore it. Once you know this, a lot of Git fear disappears.

Use it with care

  • Commands that rewrite history (amend, reset, rebase) are safe on commits only you have. If you already pushed to a shared branch, prefer revert, or talk to your team before force pushing.
  • Read the short explanation under each recipe rather than pasting blindly. Knowing why a command works is how you handle the variation of the problem the page does not list.
  • The page is intentionally short. For the model behind these fixes, pair it with an interactive tool such as Learn Git Branching or the internals chapter of Pro Git.

Common questions

Is it safe to just run the commands? Mostly, on your own local work. Be careful with anything involving reset --hard, which discards uncommitted changes, and with any fix for commits you have already pushed to a shared branch.

What if my exact problem is not listed? The page covers the most common situations only. Read the explanation of the closest recipe, then look up the command in Pro Git or the official Git documentation. Understanding what the command does to the commit graph is what lets you adapt it.

Is there a version without swearing? Yes, Dangit, Git has the same content with milder language, which is handy for classrooms and workplace wikis.

Is it enough to learn Git from? No. It is a first-aid kit, not a course. Learn the basics elsewhere and keep this for emergencies.

Best for: every developer, bookmarked before the first time something goes wrong.

gitfree courseproductivity

Ready to start?

Opens on Katie Sylor-Miller in a new tab.

Open resource
Link broken or out of date?

Report a problem

With "Oh Shit, Git!?!". Only Tauseef reads this.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.