Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uneasy development life with git submodule

Tags:

git

I have tried git submodule. Although it can solve my problem of sharing repository in projects, but using submodule has 2 issues that troubles me:

  1. The submodule folder need to commit if submodule contents has committed changes.
  2. Branch settings is not propagate into submodules. We have to manually switch branch in submodules if works in branches are across submodule.

These 2 problems introduces errors easily for daily development work. I found git slave may solve my problem.

Is there any side effect of using git slave?

Or is there are good practices to avoid the above issue in git submodule?

like image 410
Chau Chee Yang Avatar asked Oct 11 '22 15:10

Chau Chee Yang


1 Answers

The main point to be aware is quite precely described in the "Gitslave is not perfect" section:

Less obviously, there is a very loose relationship between commits in different repositories.
You cannot easily and precisely determine what commit/SHA any other repository was at when a particular commit was made (though you can approximate and assume pretty easily). Only tags provide exact synchronization between different repositories.

And that is bad in term of reproducibility (one main goal of a VCS: being able to reproduce the state of an environment at any point in its history).
You need to add tags (with a certain naming convention) in order to get back some of the tight correspondence you need between a parent repo and its sub-repos (and which is naturally present with submodules, as I explain in the true natrue of submodules).

like image 127
VonC Avatar answered Dec 15 '22 18:12

VonC