【发布时间】:2016-03-18 16:54:24
【问题描述】:
我刚刚尝试将本地计算机上某个存储库的文件迁移到另一个目录,但似乎失败了。
将源文件复制粘贴到新文件夹后,我通过以下操作尝试在新目录中执行以下操作并提交到原始 GitHub 存储库:
git init
git add .
git commit -m 'migration'
git remote add origin https://github.com/UN/REP.git
git push origin master
这(我现在已经习惯了 git)给我一个错误:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/UN/REP.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
不知道为什么会这样,我只是天真地强行推动
git push -f origin master
现在,所有文件都没有保留其编辑历史记录,因为存储库仅显示一个(强制)提交。
有什么方法可以取回此存储库的编辑历史记录?
我阅读了一些关于在/撤消强制推送后恢复的问题,但 1)我不知道他们在说什么,2)我认为我可能会因为我仍然拥有旧的 .git 文件夹而得救在我迁移之前使用的旧文件夹中。
【问题讨论】: