1

I've a projectA repository which has master branch and other feature branches gets merged into the master branch with pull requests.

Now, we're going to start a new projectB which will have everything as same as projectA with few features turned off and will have few new features that are not needed in projectA. Two different teams will be working on projectA and on projectB. If something gets added in projectA then projectB also needs to be updated with latest changes.

I do not want to create separate repositories for projectA and for projectB. How do I manage these 2 projects under one repository? Should I create two branches projectA and projectB from the master branch?

SwissCodeMen
  • 2,397
  • 3
  • 12
  • 21
Valay
  • 1,923
  • 2
  • 32
  • 80
  • 1
    You should fork the repository. The second they diverge, they are no longer the same application and should not be treated like they are. – Daniel Mann Apr 28 '21 at 16:33
  • 1
    If you managed the repositories on GitHub, this [article](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) will help you. So you need the forked repository not for experiment, but for the projectB. – SwissCodeMen Apr 28 '21 at 16:37

2 Answers2

0

The way most people do this type of thing is with two separate repositories, but I do not particularly like the proliferation of repositories, no matter how popular it is.

The second most popular option would be to use two branches. It does involve some bureaucracy every time you make a change to one branch and want to apply the same change to the other branch, but that's the type of thing that git was made for. (I believe you will find the cherry-picking option quite useful.)

A rather unpopular and possibly blasphemous option would be to keep both projects in the same repository, just in separate subdirectories. (That's the option likely to be chosen by people who are more familiar with SVN, or who appreciate SVN's simplicity over git's ability to do everything but with a huge complexity cost.) Of course if you follow that approach then each time you want to cross-apply a change you will have to do it manually.

Mike Nakis
  • 46,450
  • 8
  • 79
  • 117
0

you can add two branches (master_A, master_B) and behave like a master branch and keep them protected form overwrote and send your merge request directly to one of them

Pouya Imani
  • 106
  • 5