Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git for two applications with one different file

Tags:

git

I have a very same application under development for two institutions. All the code is 100% similar except for the names in a single properties file. In future, improvements needed are also shared between these two. Is it possible to manage source code for both applications under one git repository, so that improvements and bug fixes will be very easy, but will have different properties files?

like image 407
Buddhika Ariyaratne Avatar asked Dec 04 '22 10:12

Buddhika Ariyaratne


2 Answers

Yes, use branches.

First commit everything that is common, including a common (possibly never going to be actually used) version of the file in question:

(1)

Then, create a branch and add the changes to that file:

   (2)   <-- customer A
  /
(1)

Then update back to the original changeset, and create another branch with the other changes to that same file:

   (2)   <-- customer A
  /
(1)
  \
   (3)   <-- customer B

Then you develop from the (1) branch forward, merging into the respective (customer?) branches as you see fit:

   (2)---------(6)                        <-- customer A
  /           /
(1)---(4)---(5)---(8)---(9)               <-- development trunk
  \           \
   (3)---------(7)                        <-- customer B

etc.

Note that this can quickly become unwieldy if you have many customers, or many such smaller differences, there might be other ways to handle the differences, such as a build system that replaces a file as part of the build, instead of having N branches for such minor differences.

In other words, if the differences are related to things like branding and features that each customer have access to, a build system would prepare different distributables for each customer, already configured with the right files and configuration. This would need no extra branches at all (beyond what you should already have related to development, testing, production, etc.).

like image 135
Lasse V. Karlsen Avatar answered Dec 06 '22 22:12

Lasse V. Karlsen


I would not put configuration files under version control in this case - just state in the README that a configuration file based on given example template should be provided, e.g. database credentials.

If the template changes, you just update the README.

like image 26
moonwave99 Avatar answered Dec 06 '22 23:12

moonwave99