3 ms·
The very short of submodules is this: Git's data system has 3 (& 1/2) types of objects: 1. A blob, which is analogous to a file, and is referenced by the hash
by AceJohnny2 2y ago
The very short of submodules is this:
Git's data system has 3 (& 1/2) types of objects:
1. A blob, which is analogous to a file, and is referenced by the hash of its contents
2. A tree, which is analogous to a directory, which contains blobs and other trees, and maps them to names. It is referenced by the hash of its contents.
3. A commit, which contains One (1) tree (the top-level of your repo), a reference to one (or more, for a merge) parent commit, and miscellaneous metadata like the author and the commit message. It is referenced by, you guessed it, the hash of its contents! (annotated tags are commit objects)
3.5. References, which are analogous to symlinks to commits. Branches and lightweight (non-annotated) tags are References.
Now, remember how a tree can contain a blobs or other trees? What if (gasp) you put a commit object in them!? That's essentially what a submodule is.
That's why a submodule is always included _at a particular commit of it_. That's why there's all sorts of complicated support machinery to make "a commit object inside a tree object" make sense.
- IshKebab 2y ago> a submodule is always included at a particular commit Actually you can make a submodule track a branch instead of a specific commit. I've never seen anyone actually do that though and it seems like a bad idea. Though I did work for a while for a company that had written a custom tool that worked like that and we never ran into any problems due to it.
- eru 2y agoWhat's the hash of a branch?
- IshKebab 2y agoIt uses the branch name instead of the hash.
- AceJohnny2 2y agoI don't think it is possible to put a branch name into a tree object, not without deep modifications to git, so I suspect your previous company developed a significantly different tool around it.
- IshKebab 2y agoMy previous company wasn't using native Git submodules. I think you're right actually the submodules. You can associate a submodule with a specific branch, but it still records the hash like normal and you still have to manually update it.