How do I check out a specific version of a submodule using ‘git submodule’?

Submodule repositories stay in a detached HEAD state pointing to a specific commit. Changing that commit simply involves checking out a different tag or commit then adding the change to the parent repository. $ cd submodule $ git checkout v2.0 Previous HEAD position was 5c1277e… bumped version to 2.0.5 HEAD is now at f0a0036… version … Read more

Rename a git submodule

Git1.8.5 (October 2013) should simplify the process. Simply do a: git mv A B “git mv A B“, when moving a submodule A has been taught to relocate its working tree and to adjust the paths in the .gitmodules file. See more in commit 0656781fadca1: Currently using “git mv” on a submodule moves the submodule’s … Read more

Why is my Git Submodule HEAD detached from master?

EDIT: See @Simba Answer for valid solution submodule.<name>.update is what you want to change, see the docs – default checkout submodule.<name>.branch specify remote branch to be tracked – default master OLD ANSWER: Personally I hate answers here which direct to external links which may stop working over time and check my answer here (Unless question … Read more

Git submodule update

This GitPro page does summarize the consequence of a git submodule update nicely When you run git submodule update, it checks out the specific version of the project, but not within a branch. This is called having a detached head — it means the HEAD file points directly to a commit, not to a symbolic … Read more

Git diff says subproject is dirty

Update Jan. 2021, ten years later: “git diff“(man) showed a submodule working tree with untracked cruft as Submodule commit <objectname>-dirty, but a natural expectation is that the “-dirty” indicator would align with “git describe –dirty“(man), which does not consider having untracked files in the working tree as source of dirtiness. The inconsistency has been fixed … Read more

Issue with adding common code as git submodule: “already exists in the index”

I’m afraid there’s not enough information in your question to be certain about what’s going on, since you haven’t replied to my follow-up question, but this may be of help in any case. That error means that projectfolder is already staged (“already exists in the index”). To find out what’s going on here, try to … Read more