简体   繁体   English

如何将我的应用程序还原到我对github的特定提交

[英]how to revert my app to a specific commit I made to github

I have done some stuff to my git repo and I think I am digging the hole deeper. 我已经为我的git repo做了一些事情,我想我正在深入挖洞。

Right now I just want to be able to get all my current files in the state they were when I last pushed to github. 现在我只想让我所有当前的文件处于我上次推送到github时的状态。 However, I do not have internet connection on that machine. 但是,我在那台机器上没有互联网连接。 So what do I do? 那我该怎么办? I do have git internally and git log shows that the commit I want starts with c3e535f8cb..... 我内部有git, git log显示我想要的提交以c3e535f8cb.....

I just want to revert my whole directory to that commit. 我只想将整个目录还原到该提交。 is this doable with git? 这是可以用git吗?

right now I have nothing to commit 现在我没有任何承诺

git status shows git status显示

# on branch master
# your branch is ahead of 'origin/master' by 3 commits
#  nothing to commit (working directory clean)

Try the following: 请尝试以下方法:

git reset --hard c3e535f8cb

Note: you will lose changes in your repo, index and working directory since c3e535f8cb. 注意:自c3e535f8cb起,您将失去repo,index和工作目录中的更改。 Look into other options --soft --mixed if needed. 查看其他选项--soft --mixed如果需要,可以混合使用。 but since you don't seem to have anything to commit ( cleand wd and index ), you can do the above. 但由于你似乎没有任何东西需要提交(cleand wd和index),你可以做到以上几点。 But you will lose commits. 但是你会丢失提交。 Use git reflog to get them back and then again use git reset to "reset" to those commits. 使用git reflog将它们取回,然后再次使用git reset来“重置”到这些提交。

I strongly recommend that you do a dry-run with the --soft option to make sure that you get the desired results. 我强烈建议您使用--soft选项进行干运行,以确保获得所需的结果。

If you don't have pushed the new changes upstream, you could easily fetch the upstream changes again, and then do a reset which suits better. 如果您没有在上游推送新的更改,则可以轻松地再次获取上游更改,然后执行更适合的更改。

I hope that you made it through successfully with the goals that you set out to accomplish :) 我希望你成功实现了你要完成的目标:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM