【问题标题】:recover myfile.py following a wrong git operation [duplicate]在错误的 git 操作后恢复 myfile.py [重复]
【发布时间】:2020-06-10 09:47:59
【问题描述】:

我想在错误的 git 操作后恢复 myfile.py。

这就是我所做的:

git add myfile.py
git checkout 0ddb6x myfile.py (wrong operation, which changed the content myfile.py on my local machine)
made some change on myfile.py
git add myfile.py (wrong operation)

现在我希望在结帐前回到 myfile.py。有可能吗?

【问题讨论】:

标签: git undo recover


【解决方案1】:

所以你添加了文件,然后再次检查它。 该结帐应该什么都不做,这意味着无论出于何种目的和目的,您所做的只是git add

通过在进行更改后执行另一个git add,您已将这些更改添加到索引中,它会在提交文件之前记录文件的外观。

你到底想回到什么?磁盘上的文件只能恢复到发出任何git add 命令之前的时间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 2019-10-05
    • 1970-01-01
    • 2017-08-03
    • 2017-03-21
    • 2020-10-09
    相关资源
    最近更新 更多