Alex Rivera | Logout

How to manage multiple versions of a project?

Asked 2012-08-28T05:46:02.217
60

I have a project that is open sourced using git for revision control. Soon, I am going to release a premium hosted version of the project as well, but there will be changes made to the code specifically for the premium hosted version (performance, etc.), that should not exist in the open source version.

I want to avoid having two separate directories/projects, because if I fix a bug in the open source version, that bug is most likely in the premium hosted version as well. I don't want to make changes in two places.

What is the best way to manage this? Simply branching in git won't work right, because some files need to have 2 versions: an open source version and a premium hosted version.

Edit
Report

1 Answer

45

And yet, branching should work, and will allow you to maintain two separate versions.

If you have a bug which applies to the premium version, fix it on master, and merge it on premium branch.
Git will only merge what has changed since you branched between master and premium, ie your bug fix.
On another way to publish an hotfix both in master and premium would be to do it from the common ancestor: see "Git merging hotfix to multiple branches".


Update 2015: git 2.5 (July 2015) has replaced git-new-workdir presented below by the new command git worktree add <path> [<branch>].

For more, see "Multiple working directories with Git?".


Original answer 2012:

me-and mentions in the comments the command git-new-workdir.
See:

One solution to this is to simply create another local clone of your repository. Git automatically uses hard links when you clone locally, so

answered 2012-08-28T06:00:15.870

Your Answer