开发者

How can I sync files in two different git repositories (not clones) and maintain history?

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 fi开发者_开发技巧le 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.


I'm assuming you want perlfaq history in perl repo. I'd do this (in a perl repo)

git remote add perlfaq git://perlfaq... # real uri
git checkout perlfaq/master -b perlfaq
git checkout master # or whatever
git merge perlfaq

contrary to popular belief git does not have to have a common history to perform merge. I know I was merging 3+ repo's this way in regen2. This may be painful the first time. But after that it shouldn't be too painful. Unfortunately you can only merge 1-way but you can probably cherry-pick patches from the perl repo into perlfaq if you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜