I have pushed one of my branch before committing the changes and then checked out to another branch. then I have done git reset to make this branch similar to origin. Also the remote branch has been deleted. Now when I switch back to the first branch, I am not seeing the files which was there. These files has been added , but not committed. How can I restore the files ?
Asked
Active
Viewed 1,701 times
0
-
1See http://stackoverflow.com/q/1108853/4289417. "git fsck --cache --no-reflogs --lost-found --unreachable HEAD" should help. – Pavel Chernikov Apr 27 '16 at 05:54
-
This has given me an unreachable blob. Now what I can do with that ? – Happy Coder Apr 27 '16 at 05:56
-
1Err no you can't check it out actually. See the link for details, but you can run, for example "git show -p --format=raw $blob" on it, etc. Also see .git/lost-found. – Pavel Chernikov Apr 27 '16 at 05:59
-
Yes done it. You saved my day – Happy Coder Apr 27 '16 at 06:03
-
You should add that as a answer @PavelChernikov. That's some serious git magic! :) – crea1 Apr 27 '16 at 06:42
1 Answers
-1
Run the following to show unreachable git objects:
git fsck --cache --no-reflogs --lost-found --unreachable HEAD
To place them in .git/lost-found, skip the --unreachable flag.

Pavel Chernikov
- 2,186
- 1
- 20
- 37