我怎样才能从一个错误的git push -f起源大师中恢复过来? [英] How can I recover from an erronous git push -f origin master?
问题描述
我刚刚使用 - force
选项向我的项目提交了错误的源代码。
是否有可能还原?我知道所有以前的分支已被 -f
选项覆盖,所以我可能搞砸了我以前的修订版本。
如果你有正确的然后你可以用 --force
选项将它推入远程。除非你告诉它,否则Git不会删除任何分支。如果你实际上已经失去了提交,请看看这个恢复提交的有用指南。如果你知道你想要的提交的SHA-1,那么你可能确定。
最好的办法:把所有东西都备份好,看看你的本地还有什么库。如果可能,请在遥控器上执行相同操作。使用 git fsck
来查看是否可以恢复,最重要的是不要运行 git gc
最重要的是,不要使用 - force
选项,除非您确实是真的。
I just committed the wrong source to my project using --force
option.
Is it possible to revert? I understand that all previous branches have been overwritten using -f
option, so I may have screwed up my previous revisions.
Git generally doesn't throw anything away, but recovering from this may still be tricky.
If you have the correct source then you could just push it into the remote with the --force
option. Git won't have deleted any branches unless you told it to. If you have actually lost commits then take a look at this useful guide to recovering commits. If you know the SHA-1 of the commits you want then you're probably OK.
Best thing to do: Back everything up and see what is still in your local repository. Do the same on the remote if possible. Use git fsck
to see if you can recover things, and above all DO NOT run git gc
.
Above above all, never use the --force
option unless you really, really mean it.
这篇关于我怎样才能从一个错误的git push -f起源大师中恢复过来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!