git 恢复到某个提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6794110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git revert back to certain commit
提问by David
how do i revert all my files on my local copy back to a certain commit?
我如何将本地副本上的所有文件恢复到某个提交?
commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe <[email protected]>
Date: Thu Jul 21 20:51:38 2011 -0500
This is the commit i'd like to revert back to. any help would be a lifesaver!
这是我想恢复的提交。任何帮助都将是救命稻草!
回答by Andy
git reset --hard 4a155e5
Will move the HEAD back to where you want to be. There may be other references ahead of that time that you would need to remove if you don't want anything to point to the history you just deleted.
git reset --hard 4a155e5
将 HEAD 移回您想要的位置。如果您不希望任何指向您刚刚删除的历史记录的内容,那么在此之前可能还有其他引用需要删除。
回答by Kit Ho
You can revert all your files under your working directory and index by typing following this command
您可以通过键入以下命令来恢复工作目录和索引下的所有文件
git reset --hard <SHAsum of your commit>
You can also type
你也可以输入
git reset --hard HEAD #your current head point
or
或者
git reset --hard HEAD^ #your previous head point
Hope it helps
希望能帮助到你
回答by marcelog
http://www.kernel.org/pub/software/scm/git/docs/git-revert.html
http://www.kernel.org/pub/software/scm/git/docs/git-revert.html
using git revert <commit>
will create a new commit that reverts the one you dont want to have.
usinggit revert <commit>
将创建一个新提交,该提交还原您不想要的提交。
You can specify a list of commits to revert.
您可以指定要还原的提交列表。
An alternative: http://git-scm.com/docs/git-reset
另一种选择:http: //git-scm.com/docs/git-reset
git reset
will reset your copy to the commit you want.
git reset
将您的副本重置为您想要的提交。