0

Possible Duplicate:
How to keep public and private versions of a git repo in sync?

We have an application that is open sourced on GitHub using git, but we want to split and create a new version of the project which is premium i.e. we are going to add features that aren't available in the open source version. We still need to be able to make fixes and changes to the open source version though.

The problem is that we can't simply create a branch because the the premium version should be a private repo on GitHub, where the open source version is public on GitHub.

So, if we simply create a new private repo on GitHub and clone the existing project, now we have two separate projects and when we make changes/fixes, we have to apply those to both. Is there anyway to manage this?

The workflow is most of the changes will only apply to the premium version, but we may need to patch and fix things which should apply to both the open source and premium version.

Community
  • 1
  • 1
Justin
  • 42,716
  • 77
  • 201
  • 296
  • Not sure if github supports it, but I would try creating a fork that is a private repo. It should be possible to create a private repository in github, and add it as a remote of a current working copy, and then push everything to the new remote. – Gonzalo Nov 04 '12 at 19:18
  • GitHub doesn't seem to allow me to fork my own repo. :( – Justin Nov 04 '12 at 19:22

1 Answers1

2

You can select which repository and branches you push to.

The first step is to add two seperate repositories to your project:

git remote add private-repo git@github.com:user/private_repo.git
git remote add public-repo git@github.com:user/public_repo.git

Create two branches:

git branch private-branch
git branch public-branch

Set the default repositories to push to:

git branch --set-upstream private-branch private-repo/master
git branch --set-upstream public-branch public-repo/master

Alternatively, git pushallows you to specify which remote branch to push to.

git push private-repo private-branch:master
mabako
  • 1,213
  • 11
  • 19
  • This does not seem to work with GitHub for Mac client, it simply just synced the private-branch to the public-repo. Seems it does not support multiple remotes. – Justin Nov 04 '12 at 19:35
  • The GitHub applications for Mac and Windows aren't superb git clients, they're simple to use for most people. The so-called 'sync' function (I've only ran Github for Windows) syncs all branches. Your best bet is git from command line. – mabako Nov 04 '12 at 19:42