Accidentally reverted to master, lost uncommitted changes [closed]

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 changes, 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.

Leave a Comment