Skip to content

Instantly share code, notes, and snippets.

@fiore
fiore / git-recover-branch-commit.md
Last active March 31, 2019 10:49 — forked from jbgo/git-recover-branch.md
How to recover a local branch or a commit you accidentally deleted

*** How to recover a local branch or a commit you accidentally deleted ***

Have you accidentally deleted a local git branch, and you haven't pushed it to a remote server yet, losing several important commits? Have you accidentally lost some code you have written resolving conflicts? How do I find the missing branch or commits? This is the solution!

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!