git 撤消反向提交源树
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21986131/
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
Undo reverse commit source tree
提问by Chahal
I have accidently done a reverse commit of a branch on which I was working on. Is there any way to undo that reverse commit and get my changes back?
我不小心对我正在处理的分支进行了反向提交。有什么办法可以撤消反向提交并恢复我的更改吗?
采纳答案by Jake
This is the answer you're looking for.
It shows how to find your committed files in history and reset to them.
它显示了如何在历史记录中找到您提交的文件并重置它们。
回答by Lajos Veres
If you reseted the head of your branch than you need the old head's sha1. Maybe you can find it in the .git/objects directory by date. (try git show xyz with the suspicious sha's. (suspicious means the modification time can match.))
如果您重置了分支的负责人,那么您需要旧负责人的 sha1。也许您可以在 .git/objects 目录中按日期找到它。(尝试 git show xyz 与可疑 sha 的。(可疑意味着修改时间可以匹配。))
If you commited a "reverse" commit, than you have to repeat only what you did. (commit an other reverse commit.)
Or you can also reset the head to remove the "reverse" commit from your branch's history.
(git reset --soft 'HEAD^'
)
如果你提交了一个“反向”提交,那么你只需要重复你所做的。(提交另一个反向提交。)或者您也可以重置头部以从分支的历史记录中删除“反向”提交。( git reset --soft 'HEAD^'
)
There are a few helpful description: How to undo last commit(s) in Git?
有一些有用的描述:How to undo last commit(s) in Git?
回答by Andreas Wederbrand
If you get the SHA of the original commit (the one you later reversed) you can cherry-pick that one back to HEAD.
如果您获得原始提交的 SHA(您后来撤消的那个),您可以将其挑选回 HEAD。
Or you can just reverse the reverse. It will basically be the same thing.
或者你也可以反过来。基本上是一样的。