Git:在使用git checkout之前如何恢复本地编辑< old-revision> <文件&gt ;? [英] Git: how to revert the local edit before using git checkout <old-revision> <file>?

查看:1859
本文介绍了Git:在使用git checkout之前如何恢复本地编辑< old-revision> <文件&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个文件 file.txt
我已经做了一些修改,现在我已经在我的工作副本中进行了编辑,阶段或提交这些编辑。

然后我使用 git checkout< an-old-revision> file.txt file.txt 返回到旧提交。

现在我后悔我的结帐,怎么办我把我的编辑带回来了吗?

解决方案

使用git无法获得这些本地更改,因为您从未提交/添加或隐藏它们。如果您使用Eclipse或IntelliJ Idea等IDE,那么我会检查的第一件事是如果您可以通过文件的本地历史记录恢复您的更改。如果您不使用IDE,则备份将会很有帮助。


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.

Then I use git checkout <an-old-revision> file.txt, the file.txt goes back to an old commit.
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. 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. If you do not use an IDE then a backup would be helpful.

这篇关于Git:在使用git checkout之前如何恢复本地编辑&lt; old-revision&gt; &LT;文件&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆