Git 恢复未提交的更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3240436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git recover uncommitted changes
提问by Lakshman Prasad
I had a lot of local changes.
我有很多地方上的变化。
I just accidentally did
我只是不小心做了
git merge another_branch
git reset --hard HEAD^
on a lot of work. :( with the intention I didn't want the merged changes in here.
在很多工作上。:( 我不希望在这里合并更改。
How do I recover the original state?
如何恢复原始状态?
No, the local changes were never committed/stashed.
不,本地更改从未提交/隐藏。
No way?
没门?
采纳答案by jamessan
If the changes had never been committed/stashed/staged, then you're out of luck. If they have, then you should be able to git your changes back by looking for them in git reflog
.
如果从未提交/隐藏/暂存更改,那么您就不走运了。如果有,那么您应该能够通过在git reflog
.
回答by Nabil Mohammed Nalakath
Foy anyone who is facing this problem in ide's, there is a solution. Search For the ide editor history files of your ide. I had a problem with android studio so here i will give you a solution for android studio.
对于在 ide 中遇到此问题的任何人,都有一个解决方案。搜索 ide 的 ide 编辑器历史文件。我在 android studio 上遇到了问题,所以在这里我会给你一个 android studio 的解决方案。
For eg: In android studio you can always see the previous files , by right clicking on project folder->LOcal History->Show History.
例如:在 android studio 中,您始终可以通过右键单击项目文件夹-> 本地历史记录-> 显示历史记录来查看以前的文件。
You can see the change history of files and you can also open the files and compare it with new files side by side. If you need old code just copy paste it from there.
您可以查看文件的更改历史记录,还可以打开文件并将其与新文件并排比较。如果您需要旧代码,只需从那里复制粘贴即可。
回答by Eric Walker
Although the uncommitted modifications to tracked files will have been lost, I think any untracked files will still be around unless you subsequently deleted them.
尽管对跟踪文件的未提交修改已经丢失,但我认为任何未跟踪文件仍然存在,除非您随后将其删除。
回答by avrsanjay
Try undoing on the file directly from the IDE. You'll get what you need.
尝试直接从 IDE 撤消文件。你会得到你需要的。
Probably not helpful for @Lakshman Prasad, but will help someone else :-D
可能对@Lakshman Prasad 没有帮助,但会帮助其他人:-D
回答by Dan Alboteanu
look into Recycle Bin! I found my deleted(uncommitted) files there
看看回收站!我在那里找到了我已删除(未提交)的文件