1

I have a question regarding maintaining multiple repositories in git.

I currently have 2 projects divided into 3 folders: Landing, Admin, Stores. Which in turn the two projects are divided into US and MX. So we have US: 1, 2, 3 and MX: 1, 2, 3.

Maintaining the individual folders is not a problem, the problem is that the two projects share most of the code (Almost a mirror) except for some small changes such as type of currency, language, etc.

My question is, how can I make, for example, that the MX project is a constant copy of US and that every time I make changes in US they are easily integrated into MX?

The current way i have right now is:

  • In the US repository I have a branch called MX.
  • I download the branch integrated with Master.
  • I integrate the changes and verify everything manually (that nothing is overwritten)
  • Once everything is verified, I copy and paste all the files in the MX repository folder.
  • I update MX.

As you can see, it's a tedious process, and being 3 folders, it's almost untenable.

4
  • 1
    Are you just switching hardcoded prices, currency units, output strings, and other locale-specific things between the two versions? If the logic is identical between the two, then you should probably explore internationalizing your code rather than trying to do something complicated and brittle in Git. Commented Mar 29, 2023 at 17:56
  • Yes, there are only few changes: payments, language, images, text, DB, etc. Im following the previous way of working of the company, but i find this a little messy. I was thinking in making a main repository, and two branches: US and MX, so the code its the same. But i don't know what is the correct way to do this, or if theres a chance to overwrite things @JimRedmond
    – Saltaro
    Commented Mar 30, 2023 at 14:35
  • Indeed, everything that goes along with the DRY principle is a good strategy in general. In your case, having a single repository (and a single branch) for both projects that share almost all the code sounds sensible, and there are standard strategies to handle contributions or deployments in subfolders, typically search keywords subtree, monorepo and continuous deployment.
    – ErikMD
    Commented Mar 30, 2023 at 15:08
  • 1
    The best approach, at least to start, would be to have a language-specific file that includes appropriate translations of all the different strings used in your output or interface, mapped to a common variable name. You'd then update the code to refer to the variable, instead of a hardcoded string. This would not only let you keep the code consistent between languages, but it'd also make it much, much easier to add new languages later as necessary. Commented Mar 30, 2023 at 16:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.