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

Posted by brian d foy on Stack Overflow See other posts from Stack Overflow or by brian d foy
Published on 2009-12-07T19:14:27Z Indexed on 2010/04/23 21:23 UTC
Read the original article Hit count: 364

Filed under:

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?

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?

© Stack Overflow or respective owner

Related posts about git