Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accidentally reverted to master, lost uncommitted changes [closed]

Tags:

git

While working on Master branch, I forgot to create new branch. Made changes to files then inadvertently reverted to the master, loosing all updates. I didn't commit the updated files.

How can I retrieve them?

like image 629
Trist Avatar asked Aug 22 '11 12:08

Trist


1 Answers

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.

like image 133
Sailesh Avatar answered Oct 13 '22 04:10

Sailesh