Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
还原github存储库_Git_Github - Fatal编程技术网

还原github存储库

还原github存储库,git,github,Git,Github,我无法将文件夹推入错误的存储库。在我推送它之前,这个存储库中有几个文件。 在git将文件夹推送到该存储库后,我在此存储库中以前的文件将消失。我通过git reset--hard HEAD和git push--force还原了文件夹,但没有还原存储库 有人知道如何取回我在此存储库中的上一个文件吗 重置/撤消上一次提交,然后强制推送,或者将提交还原为推送到repo # undo the last commit $ git reset --hard HEAD~1 $ git push -f # r

我无法将文件夹推入错误的存储库。在我推送它之前,这个存储库中有几个文件。 在git将文件夹推送到该存储库后,我在此存储库中以前的文件将消失。我通过git reset--hard HEAD和git push--force还原了文件夹,但没有还原存储库


有人知道如何取回我在此存储库中的上一个文件吗

重置/撤消上一次提交,然后强制推送,或者将提交还原为推送到repo

# undo the last commit
$ git reset --hard HEAD~1
$ git push -f

# revert the last commit (safe)
$ git revert HEAD~1..HEAD       # revert the last commit with new commit
$ git push

你基本上摧毁了上游和本地回购协议。使用reflog查看错误添加目录的位置,并再次执行重置和强制。希望你没有和其他人分享回购协议。如果是这样的话,今天会有一些人头滚滚。在
other_repo
的历史记录中,你有没有强制推送文件夹之前的文件夹状态?嗨@ckruczek,我终于从中解决了我的问题support@github.com. 我仍然非常感谢您的建议。@LeGEC,我没有其他报告的历史记录,因为我是在github上编辑的,而不是在本地存储库上编辑的。最后我得到了我在github上所做的所有日志support@github.com,并取回我的所有文件。好的。仅供参考:您可以使用:
git reflog/
感谢您的帮助,在您自己的本地驱动器上查看远程分支的所有副本。