【发布时间】:2016-05-25 01:13:27
【问题描述】:
我把我的代码搞砸了,我想把它恢复到最后一次提交。
我正在做git status,我看到我更改了很多文件。我根本不想看到他们。所以我做了git log 并找出了最后一次提交的哈希值。
我在命令中使用了这个哈希:git fetch origin this_hash 并得到了消息:
Mig-macbook-air:ios M$ git fetch origin this_hash
From https://github.com/linkto/myrepo
* branch this_hash -> FETCH_HEAD
但是当我执行git status 时,我仍然看到损坏的文件,而且我在我的 IDE 中也看到了它们。我想完全摆脱这些变化,我该怎么做?
我没有推送最后一次提交;我刚刚创建了一个分支并进行了提交。
【问题讨论】:
-
你读过How do you discard unstaged changes in Git?和How do you undo the last commit?或Revert Git repo to a previous commit。如果是,为什么这些解决方案对您不起作用?如果没有,为什么不先搜索?