Git submodules are supported by git-annex since version 5.20150303.
Git normally makes a .git file in a
submodule, that points to the real git repository under .git/modules/.
This presents problems for git-annex. So, when used in a submodule,
git-annex will automatically replace the .git file with a symlink
pointing at the git repository. (When the filesystem doesn't support
symlinks, an adjusted unlocked branch is used, and submodules are
supported in that setup too.)
With that taken care of, git-annex should work ok in submodules. Although this is a new and somewhat experimental feature.
The conversion of .git file to .git symlink mostly won't bother git.
Known problems:
- If you want to delete a whole submodule,
git rm submodulewill refuse to delete it, complaining that the submodule "uses a .git directory". Workaround: Userm -rfto delete the tree, and thengit commit.

The above issue is being discussed at Git checkout fails using --recurse-submodules.
DavidD's comment #2 is misleading,
git submodule updatedoes work fine when you've checkout out a branch and want to update an existing submodule.When
git submodule updatedoes not work 100% is the case where you checked out a branch, added a submodule in that branch, and then checked out another branch that does not contain the submodule. What happens then is:And the solution is to
rm -rf submanually. This is essentially the same problem discussed above on this page where it talks about deleting a whole submodule.$repo/.git/...? If git can figure out that the.gitfile points to the actual location of the.gitfolder (in the parent repo) than I would think that git annex can conclude this as well. Again, I don't know how the guts of git annex works, so there is possibly other considerations that I am missing.$repo/.git/..., but if.gitis a file, that doesn't work.The submodule .git file having been converted to a symlink is still a problem when using
git checkoutwith--recurse-submodulesin the parent repo. The previous poster's solution to usegit checkout mybranch && git submodule updatedoes not work with git version 2.40.0 and git-annex version 10.20230407.Are there other suggestions for workarounds?
The original post states that the .git as a symlink fixes problems that exist for a .git file which points to the
.git/modules/folder of the parent. What problems are these problems?After setting up git-annex in one of my submodules, I noticed that executing
git checkout mybranch --recurse-submoduleswill cause a fatal error (see error message below) and my working copy will be left in a state somewhere in between the origin and the destination branch.As a workaround, this two-step alternative seems to work fine though:
git checkout mybranch && git submodule update.Everything above applies to command
git switchas well.I use git version 2.27.0 and git-annex version 8.20200618
Error Message: fatal: could not open 'path/to/my/submodule/.git' for writing: Is a directory