Reputation: 811
I can't seem to find the right search terms to answer this question so I'll write a new one. If there's a similar question somewhere with a good answer, I'll be happy to accept that/close this.
This would be my project structure
/Project/
/Project1
/Project2
/Project3
Project2 depends on Project1, Project3 depends on Project2, but I don't think that's entirely relevant.
Right now, each of Project1, Project2 and Project3 has its own separate Git repository. This is fine except quite troublesome to manage since I do parallel development on all three at the same time because of the dependencies.
What I would like is to put a single repository at the Project/
folder, and have 3 separate branches that each track their own folder's changes. So when I commit changes to Project2 and Project3, both Project2 and Project3's commit histories are affected.
The main advantage I'm looking for would be that in GitExtensions, I would be able to see and add to the commit history of individual projects, rather than having to open 3 windows, one for each repo. Is this possible?
Upvotes: 0
Views: 2004
Reputation: 669
The above scenario as put up in the question, is pretty much valid in following scenarios.
Micro-services: AWS Lambda development for example one or two develop work on an lambda, there are say 70 lambdas total. Thus, 70 folders including test and code_folder. If it was a monolithic system, you have to make sure all parts of system work together by having zero merge issue. But here each of 70 folder is independent except few global configuration and few shared folders.
Monorepo: Large companies use monorepo to manage all sub-projects of a larger project including mobile app, websites, backend and other related stuff.
Master branch may or may not have all the code, if each branch track only changes in its folder.
One way to do it, first create a shared branch for shared modules. Then, create multiple branches where each branch starts with empty folder. Never merge your branch with master, only pull shared branch merge your branch locally and push to remote branch.
Thus, every branch on remote has shared modules and your code.
Upvotes: 0
Reputation: 627
I suggest rethinking what you are trying to do.
You need to decide whether or not these projects are truly separate. If they are in fact separate, then just use different repositories. If they are not separate, then don't treat them that way; just create a single repository at the root Project/
folder. Your branches should be used to track separate features, not projects. Repositories in Git are designed to be specific to a single project, unlike in Subversion where you might put many different projects in a single repository.
The following part of your question raises a red flag:
What I would like is to put a single repository at the Project/ folder, and have 3 separate branches that each track their own folder's changes. So when I commit changes to Project2 and Project3, both Project2 and Project3's commit histories are affected.
You ask for 3 separate branches to track the changes for each project individually, but then you say you want project x's history to affect project y's history. Again, what are you really trying to achieve here? These projects are either separate or not.
I would advise against using separate branches to keep track of your projects individually. Use separate repositories for separate projects, and use branches only to work on specific functionalities that you will eventually merge back into the master branch.
Lastly, you could create a "master" repository at the Project/
level, and then use git submodules to track the sub-projects. Git-submodules may introduce unnecessary complexity though, so use them as a last resort.
Upvotes: 3