How to merge two repos without losing stars or history?

Hi there!

tl;dr: We need to merge our npm package’s private repo with its public repo and are seeking guidance on the best way to do this without losing stars or history. The public repo houses the same code as the private one and its master is updated with each version released to npm from the private repo.

We are working on fully open sourcing the project and currently have 2 repos:

  • the public repo (with the stars!) that is updated automatically whenever we release an update to the npm package
  • the private repo (with all the history!) is where the work on extending and maintaining the package is done.

While the source code and package are open source, we currently don’t accept external contribution or expose our development roadmap (beyond a changelog) and we’d like to change that. Right now we’ve landed on the following course of action:

  1. rename the private to indicate that it’s depracated
  2. push the private repo’s history to the public one
  3. rename public repo to the name of the private repo (for auto-redirect)

Then we’d get to keep our 1000+ :star: s and old public URLs would still work. What we’re concerned about is breaking all the PR links in the commit history. Is there a way for us to merge these two without creating a mess?

Are you caring mostly about the git history or the issues that were open on the old one? I feel like you will probably want to create a script to migrate the issues. I doubt there is any way to migrate stars and since it’s on your public one I feel like that covers it. Regarding git history not sure if maybe subtree merging is the right solution I would need to better understand what’s in each before recommending anything there.

Importing issues: https://github.com/IQAndreas/github-issues-import

Subtree Merge: https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging

1 Like