A tree object in turn consists of a list of objects with some metadata, e.g. Each commit object points to a tree object which represents the state of your source code at that commit. These objects can be of various types, such as “commit”, “tag”, “blob” (file), “tree” (directory), etc. Git’s model of the world is based around objects which are identified by their “object name”, which is the correct term for the SHA1sum hashes you see all over the place. If you just want recipes for how to do particular things, then you can skip to “Things You Might Need To Do” below, but I think this section is useful for figuring out problems that might arise. To answer this you need to understand a little bit about how git stores objects. ![]() Note also that version 1.7.0 and later versions of git have some annoying differences in behaviour, which are noted below. (As a small point of interest, to find out which tagged releases had these fixes, I cloned git.git and did git tag -contains 496917b.) The second problem which compounded this is that if you spelled the submodule name with a trailing slash (as is common with tab-completion) then that did not refer to the submodule, and due to the previous problem would be ignored. The first of these is that if you had a typo in the name of a submodule listed on the command line, that would be silently ignored. Many actions that you might perform that relate to submodules are done with the git submodule command, but in older versions of git this has two problems that make it very easy to get confused – I think these are important enough that everyone who uses submodules should be aware of them, and ideally upgrade their copy of git to a version that doesn’t have these problems: at least version 1.6.2. … it’s worth checking what version of git you have. (More on that below.) If you change directory into the submodule then you’ll find that it doesn’t know anything about the the parent project at all, and you can carry out operations in that repository as if it were standalone. It’s important to understand that the repository which contains a submodule knows very little about it except for which version it should be and various bits of information about how to update it. ![]() (I’ll sometimes refer to the whatdotheyknow repository as the super-project, which I hope is clear.) ![]() ![]() In each project the commonlib repository has been added as a submodule. The example I’m going to use in this post however, called whatdotheyknow, is one of the various mySociety projects that depend on a repository called commonlib, which contains useful code common to at least one project. For example, if you’re developing a new Ruby-on-Rails application, you could add a clearly specified version of the Rails repository as a submodule at the path vendor/rails. This is a useful feature when you have a project in git which depends on a particular versions of other projects. What are submodules?Ī submodule in a git repository is like a sub-directory which is really a separate git repository in its own right. Submodules in git are commonly misunderstood in various ways, and although the explanation in the official manual is clear and pretty easy to understand, I thought that a different treatment here might be useful to someone. I haven’t actually finished the FAQ bit of this post yet, but since I’m not sure when I’ll have time to do so, I’ll just publish it anyway – please let me know in the comments if this is useful for you, or there’s something else you’d like to see included.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |