英文:
How can I undo that unstaged changes were deleted by git reset --hard HEAD^?
问题
我正在进行我的项目,然后我做了一个错误的提交(最后一次提交),想要永久从git日志中删除它,我执行了以下命令:
git reset --hard HEAD^
问题是,我没有添加我的更改,所以所有未暂存的更改都被删除了。
现在,我如何恢复所有更改?
英文:
I was working on my project, and I made a wrong commit (the last commit) and wanted to permanently delete it from the git logs, and I did the following command:
git reset --hard HEAD^
The problem is that I didn't make add on my changes, so all changes which are unstaged were deleted.
Now, how do I get all the changes back?
答案1
得分: 2
根据Git文档的说明:
git reset
--hard 重置索引和工作树。自从以来,工作树中被跟踪文件的任何更改都将被丢弃。
如果没有恢复源(stash、add、commit),我不知道任何可以恢复文件的方法,因为Git不会自动更新当前工作树的快照。
英文:
As the git documentation specifies:
> git reset
> --hard Resets the index and working
> tree. Any changes to tracked files in the working tree since <commit>
> are discarded.
If there is no restore source (stash, add, commit) I know of no way to restore your files since git doesn't 'auto-updates' a current snapshot of your working tree
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论