Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD
?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
If you are trying to use the code below:
and for some reason are getting:
then try wrapping
HEAD@{1}
in quotesYou can get back a commit after doing a
reset --hard HEAD
.Make use of "
git reflog
" to check the history of theHEAD
in the branch.You will see your commit and its id here.
Do a
I just did
git reset --hard
and lost all my uncommitted changes. Luckily, I use an editor (IntelliJ) and I was able to recover the changes from the Local History. Eclipse should allow you to do the same.If you're developing on Netbeans, look between the file tabs and the file edit area. There is a "Source" and "History". On "History" you'll see changes made using version control (git/other), but also changes made locally. In this case, local changes could save you.
If you use something like IntelliJ:
On the context menu, choose Local History, and click Show History on the submenu:
http://blog.jetbrains.com/idea/2008/01/using-local-history-to-restore-deleted-files/
This just got my arse out the fire!
Correct answers. OK, now I like git. :-) Here's a simpler recipe.
Where "2" is the number of back to where you committed your changes. In my case, interrupted by colleague and boss to help debug some build issue; so, did a reset --hard twice; so, HEAD and HEAD@{1} were over-writes. Whew, would have lost an our of hard work.