After reset --hard all my untracked files are gone

為{幸葍}努か 提交于 2019-12-24 08:43:55

问题


I did a git hard reset without committing my files. After firing reset I checked all my untracked files are gone. I am expecting it will affect only the changes we made during the commit and it will simply reset those changes. But I was wrong.

Is there any way to get recover all my untracked files ? Any Help would be really really appreciated.

Thanks


回答1:


If you previously did a git add with your untracked files, then git reset --hard will delete them. Git has no process of restoring these because they are untracked. You will need to find another tool to do so, such as your operating system or IDE. IntelliJ has a "Local History" tool that you might be able to leverage for restoring these files.

For future reference, prefer git stash to git reset --hard. git stash creates a temporary "stash" commit with your changes. These can be easily retrieved with git stash apply or git stash pop. When you nuke your working directory with git reset --hard, it is much more difficult to undo, sometimes even impossible.



来源:https://stackoverflow.com/questions/52042030/after-reset-hard-all-my-untracked-files-are-gone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!