How do I add Git submodule to a sub-directory?

Question

I have a Git repo in ~/.janus/ with a bunch of submodules in it. I want to add a submodule in ~/.janus/snipmate-snippets/snippets/, but when I run git submodule add <[email protected]:...> in the snipmate-snippets directory, I get the following error message:

You need to run this command from the top level of the working tree.

So the question is: How do I add a submodule to the snipmate-snippets directory?

Answer

You go into ~/.janus and run:

git submodule add <git@github ...> snipmate-snippets/snippets/

If you need more information about submodules (or git in general) ProGit is pretty useful.

How do I fix "remote: fatal error in commit_refs" errors trying to push with Git?

Commit only part of a file's changes in Git