Using nested git repositories in git is not possible and thus this also applies to git-annex. However, here is a good workaround that I found:
Rename the .git
directory of the nested repo to dotgit
(or similar), git annex add
it and then create a symbolic link from .git
to dotgit
. It's important that the link is created only after the nested repo has been git annex add
'ed. Also, the link needs to be created manually on each clone. Finally you'll need to hide the dotgit
directory from the nested repo itself by adding /dotgit
to dotgit/info/exclude
.
mv nested/.git nested/dotgit; echo "/dotgit" >>nested/dotgit/info/exclude
git annex add nested; git commit -m "add nested"
cd nested; ln -s dotgit .git # needs to be done on every clone
I agree, submodules are the usual way to nest git repositories, and will more or less just work with git-annex.
I think that the author of this tip is wanting to version control the contents of
.git
itself. Eg, to version control.git/config
and.git/hooks/
.One problem with this approach is that when the outer repository has "dotgit/annex/objects/
files added to it, running
git-annex dropinside the nested git repository will drop the content, but the outer repository will still contain a copy too. You would have to use
git-annex unused` to eventually clean up those copies. And it stores 2 copies of every annexed file to use it this way.Using nested git repositories is well possible; if they are checked in they are called submodules, otherwise they just sit there unadded.
Apart from some odd quirx you never run into in normal operation, submodules work fine also with git-annex.