Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to handle multiple projects with lots of duplications?

I have two projects.

First I wrote the project number 1.
Then I decided to start project number 2 which was very similar to project number 1.
So I decided to clone the project number 1 and start from there.

The challenge is developing these two projects.

From now on, some changes in project number 1 have to be done in project number 2.
My problem is that I have to copy and paste some of new changes in project 2 which is exhausting and may cause problems (such as forgetting copying and pasting some codes).

Did you have any experience about this issue?
Or do you have any solutions?

like image 636
Amirreza Zarkesh Avatar asked Jan 19 '26 14:01

Amirreza Zarkesh


1 Answers

If you have common parts limited to a folder (and subfolders), you can:

  • extract that folder in its own repository
  • reference that third repository as submodule (following its main branch)

That way, each time you are making a change to that common parts in repo1, all you need to do in repo2 to get updated is:

cd repo2
git submodule update --remote
like image 179
VonC Avatar answered Jan 22 '26 02:01

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!