Working with modules in GIT


There is an external repository in which the basic functionality for working with the database is implemented, hereinafter I will call it DAL – data access layer).

I create a new project, connect the DAL as a module:

git submodule add ../Projects/DataAccessLayer DAL

In the current project, I need to finish it a little with a file , these changes are unique within the current project, in general I don't need them in the DAL repository.

How to properly organize / do such work?

UPD .:

At the moment, I have structured my work like this:

  1. Create a new branch: git checkout -b НоваяВетка ;
  2. I make the changes I need: add new classes, reorganize, and so on;
  3. Indexing changes, comic: git add ... -> git commit -m 'Здесь какой то текст' ;
  4. I merge changes into the main branch: git checkout master -> git merge НоваяВетка ;
  5. I repeat from the beginning of the list as we refactor, add new functionality;


Master v.0.1
   | \
   |  \
   |   \
   |    \
   |   v.0.1
   |    /
   |  dal
   |  /
   | /

those. I connect the module in the dal branch, we make improvements to the dal module in the branches that go from dal

did I understand correctly?


Option 1.

Think about whether it is possible to do the finishing with the help of the configuration? For example, put different constants in a separate config. As part of a submodule, you will have one config with default values, and in a specific project – the second, in which some of the values ​​can be overridden. Then the need to make changes to the submodule will disappear.

Option 2.

Make a new branch in the submodule specific to this project. Make changes to it. If you make any general changes to the DAL and want to update them in the repository, then you will need to update master, and then rebase your changes to the new last commit.

It was:

master    feature
    C   X
    | /

Will become:

master    feature
Scroll to Top