本文介绍了在事实之后,将回购标记为github中的fork的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个项目主要是通过复制/粘贴方法分叉的.但是回购之间仍然存在大量重叠.

We have a project that was forked a while back mostly via a copy/paste method. But there is still significant overlap between the repos.

是否可以将这个fork追溯地标记为github的fork,这样比较和pull请求之类的功能就可以正确执行?

Is it possible to retroactively mark this fork as a fork to github, so that functions like compare and pull requests will do the right thing?

注意:我已经尝试过下面的"hack"操作,即重新分叉,克隆fork,将"forked"内容复制过来,然后进行git add/commit/push.但是,原始"fork"中的文件历史记录丢失了,分支也不会消失.

Note: I have tried the "hack" below, of forking anew, cloning the fork, copying the "forked" content over, then git add/commit/push. However, the file histories in the original "fork" are lost, and branches don't come over.

推荐答案

由于您不想将提交内容压缩"到一个文件中,因此您可以执行以下操作:

As you don't want to "squash" your commits into a single file what you could do is:

  • 分叉原始"存储库
  • 从您的复制并粘贴"仓库创建
  • Fork the "original" repository
  • Create a pull request from your "copy and paste" repo to the fork

或者您可以看看如何合并两个存储库,例如这篇文章.就像他们在那里所做的那样,您可以将"c& p repo"作为子树添加到派生,就像它在在这里.

Or you could take a look at how to merge two repositories like in this post. Like they did there you could add your "c&p repo" to the fork as a subtree, like it is explained in detail over here.

这是指南中采取的步骤:

This are the steps taken in the guide:

git remote add -f c&prepo /path/to/c&prepo
git merge -s ours --no-commit c&prepo/master
git read-tree --prefix=vendor/c&prepo/ -u c&prepo/master
git commit

但是,即使使用这些方法,您也无法合并整个存储库,而只能合并特定的分支.您可以做的就是为每个分支创建一个拉取请求(在我的第一种方法中进行了描述),这可能会花费一些时间,具体取决于您的分支模型.

However even with those methods you aren't able to merge the whole repositories but only specific branches. What you could do is i.e. create a pull request (described in my first method) for each branch, which could take up some time depending on your branching model.

我认为实际上没有一种解决方案,您可以合并两个不同的存储库,同时保留其提交历史记录分支.祝您好运.

I don't think there actually is a solution where you can merge two different repositories while keeping their commit history and branches at the same time. Best of luck to you.

这篇关于在事实之后,将回购标记为github中的fork的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 20:14