Git - 意外覆盖远程存储库的整个提交历史记录
为了在 Git 和 SVN 之间建立一座桥梁,允许一个项目的开发人员使用 SVN,而另一个项目的开发人员使用 Git,我无意中覆盖了远程存储库中的整个 git 提交历史记录。这是导致错误的基本工作流程。
- 克隆远程 Git 存储库
按照一系列命令将 Git 存储库导入 SVN。
a.我尝试了通过 stackoverflow 和其他几个位置找到的各种方法,使用本地 SVN 存储库作为测试。考虑到我运行它们的 Git 存储库,它们中的大多数都失败了。但是,在 http://eikke 中找到的一组步骤。 com/importing-a-git-tree-into-a-subversion-repository/ 似乎成功了,所以这些就是我最终使用的。
b.这只是半成功。导入 SVN 尝试获取所有 git 提交历史记录并将其导入为 SVN 提交日志,但在进行到大约 2/3 时失败。最后三分之一作为单个提交提交到 SVN 中。此外,所有提交日期都被当前日期覆盖,并且很大一部分作者被覆盖。鉴于这是在 SVN 存储库中而不是实际的 Git 存储库中,我并不太担心。
- 让某人从 SVN 检查代码,进行更改并提交。
- 使用 git svn 获取更改
- 将更改推送到远程存储库。
最终结果是整个提交历史记录被 SVN 中现在的内容覆盖。因此,提交日期和作者发生了更改,并且最后 1/3 的提交历史记录丢失了。可以恢复吗?
如果没有,我找到了我在过程中间的某个地方制作的本地存储库的备份。它似乎拥有所有原始提交历史记录。是否有可能以某种方式用本地备份中的内容覆盖远程存储库上的提交数据?
In an attempt to create a bridge between Git and SVN that allows developers on one project to use SVN and those on another project to use Git, I inadvertantly overwrote the entire git commit history in the remote repository. Here's the basic work flow that caused the error.
- Cloned the remote Git repository
Followed a series of commands to import the Git repo into SVN.
a. I tried a variety of methods found via stackoverflow and a several other locations using a local SVN repository as a test. Most of them failed given the Git repo I was running them against. However, the set of steps found at http://eikke.com/importing-a-git-tree-into-a-subversion-repository/ appeared to be successful, so those are what I used in the end.
b. This was only semi-successful. The import into SVN attempted to grab all of the git commit history and import it as SVN commit logs, but failed when it was about 2/3rds of the way through. The last third was committed into SVN as a single commit. Further, all of the commit dates were overwritten by the current date and a large portion of the authors were overwritten. Given that this was in the SVN repo and not the actual Git repo, I wasn't too concerned.
- Had someone check out the code from SVN, make a change, and commit it.
- Used git svn to fetch the change
- Pushed the change to the remote repository.
The end result was that the entire commit history was overwritten with what is now in SVN. As such, the commit dates and authors were changed and the last 1/3rd of the commit history was lost. Is it possible to recover?
If not, I found a backup of the local repository that I made somewhere in the middle of the process. It appears to have all of the original commit history. Is it possible to somehow overwrite the commit data on the remote repository with what I have in this local backup?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将更改推送到遥控器,那么您并没有真正覆盖任何内容;毕竟,它是版本控制。您应该能够通过将 HEAD 重置到执行任何操作之前的位置来恢复遥控器的状态。假设我没有误解你所做的事情,你真正需要做的就是
......然后你就会回到你开始的地方,尽管你的失误将保留在遥控器的历史中。如果您不想这样,您需要直接操作遥控器并将 HEAD 移回原来的位置。
If you pushed the changes to the remote, you haven't really overwritten anything; it is version control, after all. You should be able to recover the state of the remote by resetting the HEAD to where it was before you did anything. Assuming I'm not misunderstanding what you did, all you really need to do is something like
... and you'll be back where you started, although your screw-up will remain in the remote's history. If you don't want that, you need to work on the remote directly and move the HEAD back to where it was.