A work in progress. As I learn more about the wonderful Git.
Embeds another Git repo within a Git repo. One handy use case is relatively referencing some common source, which is managed independently in its own Git repo. The submodule can be pinned to a particular branch by creating a
[submodule "common"] path = common url = email@example.com:fooframework/common.git branch = master
In each branch of the parent repo (the one that includes the submodule/s), you could commit slightly different versions of the
.gitmodules so that branch of the submodule lines up. For example, you may want the
develop branch of the parent repo, to use the
develop branch of the submodule. However when in the
master branch of the parent repo, you’d like the
master branch of the submodule to be used.
Every now and then I end up with a detached head. WTF is a detached head again? It happens when you checkout a specific commit, instead of a branch. The
HEAD pointer will stick to the specific commit, and no longer automatically point to the latest commit in the working branch. If you don’t realise the HEAD is detached, and get to work and make a bunch of changes, these changes can easily get lost as the correct commit/branch accounting is thrown out.
My favourite remedial action, is to stash the changes, then properly chechout the branch (not a commit!), pop the stash, stage and commit.