Managing multiple projects with git which are build up on each other and can been used independent
I’m planning an open source project which I want to publish on GitHub. I want to create several projects which extend each other. But I want the option to change a common base class which should be merged with its parent project but only that shared files the extensions without common files should be independent.
Here are my three example projects:
- How to isolate projects/folders with git that are part of a large project?
- Is asset management a superset of source control
- Using GIT with Joomla
- How to announce backward incompatible changes in OSS project?
- How should I set up a git repository with many static assets?
- How/Where do you store git repositories when working with multiple servers?
I want to implement a helpful class called ObservableArray. That class will extend a List which observes with an interface its items and propagates these changes out to registers listeners. This should be useful for multiple projects like my Project B.
I want to implement a SQlite database warper which allows a simple access to a list of rows which are just plain classes. With the help of project A it will be simple to track the changes in the data model which can be simple synced with the SQLite database.
This project should take the database warper and put it into an Android ContentProvider for some other use cases.
As you can see all three Projects are built on top of each other but Project A or Project B but a user may not need the support of ContentProviders so far I want to make that to independent projects. I think it is too much overhead to let the user of project C update all the three independed projects. So my idea was to fork one project the other so that each project can updated or how this is called in GitHub.
My questions are:
- Is it possible to fork the project so it is possible to update the base class in both directions?
- Let’s say I need to update a class of Project A what steps do I need to do to update both other projects?
- How do I prevent that I check in a file of Project C by accident in Project A? I would use different namespaces so I would be able to use a ignore list. Would this solve my problem?
I know that are quiet basic questions I tried to understand the basics of git and the fork graph from GitHub let me think that this should be possible but it seems that this only works if you have multiple accounts. Please enlighten me!
One Solution collect form web for “Managing multiple projects with git which are build up on each other and can been used independent”
It sounds like you’re looking for submodules. A submodule basically allows you to point at a specific commit in another git project. In your example you would do something like:
- Implement Project A
git initProject B then
git submodule add /project/a/url/
git submodule init && git submodule update
At this point you will see project A’s code in a sub directory of Project B as if you had
git cloned it into Project B’s directory. However, Project B’s git repository will now of a
.gitmodules file which contains the URL you used in
git submodule add. Also, now when you do
git add project-a-directory in Project B instead of committing file changes you will commit a pointer to the SHA id currently checked out in the submodule.
You should read up on the documentation, submodules are very useful but can be a bit tricky to get the hang of.
If you make changes in the Project A submodule you cannot commit them from Project B. The project A submodule has Project A’s complete git repository. To commit changes you commit them and push to Project A’s repository then commit a new pointer to the new SHA in Project B.
If remote changes are made to Project A that you want you can’t fetch them via Project B. First
cdto the submodule directory, fetch the changes and checkout the commit you now want Project B to use. Then
cd ..to Project B and commit a pointer to the new SHA id in the Project A submodule.