Accidentally reverted to master, lost uncommitted changes

I've managed to make a huge blunder (on a Monday morning) Working on Master, forget to create new branch, made changes to files then inadvertently reverted to the master, loosing all updates. I didn't commit the updated files.

Have I lost all updates or can I retrieve them?

Don't ask me how because every time I think about it I have to punch myself in the face.


If you had not commited , staged , or stashed the changes you made, there is no way you can recover those changes.

EDIT: Recovering lost changes. Adding this on Mark Longair's suggestion (in the comment). This also includes a couple of SO links from his answer below(*), that I found quite informative.

  • If you have ever committed some change and have lost that commit (like committing in a detached state), you can find that commit using reflog . See this SO question*.

  • If you have lost your last staged changed, you can also recover that. See this SO question*. (I have never used or tried it myself).

  • If you have stashed a change, you can also recover that using pop or apply . (I am not sure if the popped/dropped stashes are also recoverable that were not committed). You may find this Recover dropped stash in git useful.

  • If there are any other methods that anyone can suggest, I'd edit this answer further to add them.


    Two longshots: Some IDEs, such as Delphi, keep an editor history. You may have some recourse there.
    Next, if you had your local working directory located in the MyDocuments folder, it may have been automatically backed up by Windows Home Server, Carbonite, MozyPro, etc.. these are usually 'set it and forget it'. maybe you forgot it?


    I was stuck in the same situation.

    Had a list of the changed files in the terminal before the --hard reset, went into my editor (Sublime 2, doesn't matter though), opened each file and hit cmd+z (undo) once, this effectively undid the changes done by the hard reset and I got my uncommitted changes back :)

    链接地址: http://www.djcxy.com/p/23494.html

    上一篇: 执行后如何恢复:git reset

    下一篇: 意外地回到了主人,失去了未提交的变化