[英]Git: how to revert the local edit before using git checkout <old-revision> <file>?
Say I have a file file.txt
, I've committed some revisions and now I've edited it in my working copy, I didn't stage or commit these edits. 假设我有一个文件file.txt
,我已经提交了一些修订,现在我已经在工作副本中对其进行了编辑,但是我没有上演或提交这些编辑。
Then I use git checkout <an-old-revision> file.txt
, the file.txt
goes back to an old commit. 然后,我使用git checkout <an-old-revision> file.txt
, file.txt
返回到旧的提交。
Now I regret my checkout, how do I bring my edits back? 现在,我为结帐感到遗憾,如何恢复编辑?
With git you cannot get these local changes back because you never committed/added or stashed them. 使用git时,您无法取回这些本地更改,因为您从未提交/添加或隐藏它们。 If you use an IDE like Eclipse or IntelliJ Idea then the first thing i would check is if you can recover your changes via the local history of the file. 如果您使用像Eclipse或IntelliJ Idea这样的IDE,那么我要检查的第一件事就是您是否可以通过文件的本地历史记录恢复所做的更改。 If you do not use an IDE then a backup would be helpful. 如果您不使用IDE,则备份将很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.