我如何在两个不同的git存储库(而不是克隆)中同步文件并保留历史记录? [英] How can I sync files in two different git repositories (not clones) and maintain history?

查看:375
本文介绍了我如何在两个不同的git存储库(而不是克隆)中同步文件并保留历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护两个需要共享某些文件的不同git repos,并且我希望在一个repo中的提交显示在另一个repo中。什么是在每个回购中进行持续维护的好方法?



我一直是 perlfaq(Github),最近我担任维护Perl核心文档的角色,这也在git中。

在我开始维护perlfaq之前,它就住在一个独立的源代码控制库中。我最近把它转换成git。定期地,其中一个perl5-porters将同步perlfaq repo和perl repo中的共享文件。既然我们已经转向git,我们一直在懒惰地转换这些工具,而现在我是那样做的人。目前,为了同步Perl的新(每月)发行版的FAQ,我几乎感到羞耻。说我只是复制perlfaq repo中的 perlfaq * .pod 文件并将它们覆盖在perl repo中。这会丢失历史记录等。另外,有时候有人会对perl repo中的这些文件进行更改,并最终覆盖它(是的,请检查 git diff 您的白痴!)。这些文件在回购中没有相同的路径,但这是我可以改变的东西,我认为。



我想在魔法世界中做什么的彩虹和小马,从perlfaq repo中提取对象并将它们应用到perl repo中,反之亦然,因此历史记录和提交id在每个对应中都是相应的。


  • 创建补丁程序有效,但管理它也很麻烦

  • Git子模块似乎只能用于引入整个外部回购

  • 我还没有找到类似svn的文件外部的东西,但无论如何这两个方向都可以工作。

  • 我很想从一个对象中拾取对象,并选择cherry-pick他们在另一个



有什么好的方法来管理这个?

解决方案

子树合并策略,结合脚本 <强> git subtree ,可能在这里有所帮助。

它可以用于推和拉。

它还有一些包含合并,尽管Git1.7.0将使用' -Xsubtree '选项,但仍值得研究。


I maintain two different git repos that need to share some files, and I'd like the commits in one repo to show up in the other. What's a good way to do that for ongoing maintenance in each repo?

I've been one of the maintainers of the perlfaq (Github), and recently I fell into the role of maintaining the Perl core documentation, which is also in git.

Long before I started maintaining the perlfaq, it lived in a separate source control repository. I recently converted that to git. Periodically, one of the perl5-porters would sync the shared files in the perlfaq repo and the perl repo. Since we've switched to git, we'e been a bit lazy converting the tools, and I'm now the one who does that. For the time being, the two repos are going to stay separate.

Currently, to sync the FAQ for a new (monthly) release of perl, I'm almost ashamed to say that I merely copy the perlfaq*.pod files in the perlfaq repo and overlay them in the perl repo. That loses history, etc. Additionally, sometimes someone makes a change to those files in the perl repo and I end up overwriting it (yes, check git diff you idiot!). The files do not have the same paths in the repo, but that's something that I could change, I think.

What I'd like to do, in the magical universe of rainbows and ponies, is pull the objects from the perlfaq repo and apply them in the perl repo, and vice-versa, so the history and commit ids correspond in each.

  • Creating patches works, but it's also a lot work to manage it
  • Git submodules seem to only work to pull in the entire external repo
  • I haven't found something like svn's file externals, but that would work in both directions anyway
  • I'd love to just fetch objects from one and cherry-pick them in the other

What's a good way to manage this?

解决方案

The subtree merge strategy, combined with the script git subtree, might help here.
It would work for push and pull.
It has still some issue with merges, although Git1.7.0 will fix that with a '-Xsubtree' option, but it still worth looking into.

这篇关于我如何在两个不同的git存储库(而不是克隆)中同步文件并保留历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆