Reputation:
I develop a new product B on the base of a product A. Most source code of B is similar to A.
How should I use git in my development process?
Should I create a new branch on git or just insert a MACRO like below?
ifdef B
do something
endif
Upvotes: 0
Views: 71
Reputation: 15099
so the difference of the two products is just some constant parameters.
Neither branch, nor macro.
The most reliable decision would be to separate all common code from project-dependent and then introduce submodules.
Step 1. Extract all your constant parameters, e.g. in an XML or properties (key=value) file. They should be in separate classes and in a different folder.
Step 2. In project A use git-subtree command to extract all common code as a submodule. Push that submodule to its own remote.
Step 3. Start a new project for B in your IDE. Initiate a new repo and clone a submodule from remote.
Step 4. Now you have projects A and B in separate folders and repos. They share a submodule with common code. When you change the code in one project, update it with git to another. It would be good to pick one of the projects as your "development project" and make all development in it, only updating with release versions.
Upvotes: 1