Skip to content

Instantly share code, notes, and snippets.

@CoryKelly
CoryKelly / OhShitGit
Last active October 28, 2023 15:19
Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. So here are some bad situations I've gotten myself into, and how I eventually got myself out of them in plain english
## Oh shit, I did something terribly wrong, please tell me git has a magic time machine!?!
`git reflog`
### you will see a list of every thing you've done in git, across all branches!
### Each one has an index HEAD@{index} find the one before you broke everything.
`git reset HEAD@{index}`
### magic time machine`
## Oh shit, I committed and immediately realized I need to make one small change!