Why are submodules always pointing to a specific commit?

Why are submodules always pointing to a specific commit?

Unlike normal Git repositories, Submodules always point to a specific commit – not a branch. This is because the contents of a branch can change over time, as new commits arrive. Pointing at a specific revision, on the other hand, guarantees that the correct code is always present.

How to add a new commit to the submodule?

The submodule is really an independent repository – just creating a new commit in the submodule and pushing that isn’t enough. You also need to explicitly add the new version of the submodule in the main project. So, in your case, you should find the right commit in the submodule – let’s assume that’s the tip of master:

How are commits checked out in a Git submodule?

They are, like you say, just a pointer to a particular commit of the submodule’s repository. This means, when someone else checks out your repository, or pulls your code, and does git submodule update, the submodule is checked out to that particular commit.

How is a Git submodule related to a parent Repo?

A submodule is a single commit referenced by a parent repo. Since it is a Git repo on its own, the “history of all commits” is accessible through a git log within that submodule. So for a parent to track automatically the latest commit of a given branch of a submodule, it would need to: cd in the submodule

Unlike normal Git repositories, Submodules always point to a specific commit – not a branch. This is because the contents of a branch can change over time, as new commits arrive. Pointing at a specific revision, on the other hand, guarantees that the correct code is always present.

Why does git pull–recurse-submodules fail?

In that case, it is possible for git pull –recurse-submodules, or git submodule update, to fail if the superproject references a submodule commit that is not found in the submodule remote locally configured in your repository. In order to remedy this situation, the git submodule sync command is required:

What does it mean to have submodules in Git?

Submodules are references to a Git repository. This means that you can find out what files have been modified since the last commit. We can do this using the git status command. First, we’ve got a bit of configuring to do.

When to use add subcommand or add submodule?

When adding a new submodule to the tree, the add subcommand is to be used. However, when pulling a tree containing submodules, these will not be checked out by default; the init and update subcommands will maintain submodules checked out and at appropriate revision in your working tree.