Topic: info and discussion about GIT submodules for QElectroTech
i am starting this thread to list the pros cons of GIT submodules.
And what to add and what not to add
what are GIT submodules:
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed:
but keep all relevant code in 1 repo
why: for bug tracking
There are three major disadvantages to one project per repository, the way you've described it above. These are less true if they are truly distinct projects, but from the sounds of it changes to one often require changes to another, which can really exaggerate these problems:
It's harder to discover when bugs were introduced. Tools like git bisect become much more difficult to use when you fracture your repository into sub-repositories. It's possible, it's just not as easy, meaning bug-hunting in times of crisis is that much harder.
Tracking the entire history of a feature is much more difficult. History traversing commands like git log just don't output history as meaningfully with fractured repository structures. You can get some useful output with submodules or subtrees, or through other scriptable methods, but it's just not the same as typing tig --grep=<caseID> or git log --grep=<caseID> and scanning all the commits you care about. Your history becomes harder to understand, which makes it less useful when you really need it.
New developers spend more time learning the Version Control's structure before they can start coding. Every new job requires picking up procedures, but fracturing a project repository means they have to pick up the VC structure in addition the code's architecture. In my experience, this is particularly difficult for developers new to git who come from more traditional, centralized shops that use a single repository.
In the end, it's an opportunity cost calculation. At one former employer, we had our primary application divided into 35 different sub-repositories. On top of them we used a complicated set of scripts to search history, make sure state (i.e. production vs. development branches) was the same across them, and deploy them individually or en masse.
It was just too much; too much for us at least. The management overhead made our features less nimble, made deployments much harder, made teaching new devs take too much time, and by the end of it, we could barely recall why we fractured the repository in the first place. One beautiful spring day, I spent $10 for an afternoon of cluster compute time in EC2. I wove the repos back together with a couple dozen git filter-branch calls. We never looked back.
but keep the repo small source
The reason the team managers finally have accepted the split: the single Git repo (550 MB) was requiring 13 minutes to be cloned on Windows (one minute on Linux).
In essence: submodules for
- a third party library
- a piece of data that cannot negatively affect the code, and one that can become too large
eg Elements, titleblocks, and maybe docs (fetches the data from the code)
and for large files such as audio samples, videos, datasets, and graphics there is git lfs but let's wait with that. https://git.tuxfamily.org/ does not support this, I think.
cloning: this requires extra instruction
git clone qelectrotech.git qet
git and submodules
git clone --recurse-submodules qelectrotech.git qet
if I am correct, QElectroTech consists of
- project editor
- element editor
- Title block template editor
programming can quickly get complicated see: https://de-backer.github.io/qelectrotec … ditor.html
for a graphical representation of QETDiagramEditor Class (collaboration diagram).
Obviously git is valuable for finding bugs.
but what if you need to debug on user input
eg: "find class foo that ruined bar x"
I recommend splitting the code but not necessarily making it into extra submodules.
Documenting the code is recommended, but it is easy to forget.
It is more interesting if the code is self-explanatory.
eg https://de-backer.github.io/qelectrotec … indow.html
more info to come....