forum/n00b question. Can I use git-annex to manage a tree that contains git repos?git-annexhttp://git-annex.branchable.com/forum/n00b_question._Can_I_use_git-annex_to_manage_a_tree_that_contains_git_repos__63__/git-annexikiwiki2016-04-25T20:40:02Zgit-annex is githttp://git-annex.branchable.com/forum/n00b_question._Can_I_use_git-annex_to_manage_a_tree_that_contains_git_repos__63__/comment_1_ac45ad341f026289ce56183b9ff463af/clacke2016-04-22T07:44:06Z2016-04-22T07:44:06Z
<p>git-annex is first git, then some additional very neat functionality. Being git, it refuses to handle git repositories as that would create all kinds of potential confusion and inefficiency.</p>
<p>Submodules would be a way to go, if you like how they work. Or you could just ignore the git repos, as you probably have them replicated somewhere else.</p>
comment 2http://git-annex.branchable.com/forum/n00b_question._Can_I_use_git-annex_to_manage_a_tree_that_contains_git_repos__63__/comment_2_53e0ffe901a1a1c22361bfd7cf71affd/interstar2016-04-22T12:38:16Z2016-04-22T12:38:16Z
OK. Thanks.
furthermore..http://git-annex.branchable.com/forum/n00b_question._Can_I_use_git-annex_to_manage_a_tree_that_contains_git_repos__63__/comment_2_f7416c26daca543ad08c11e187e1589e/joey2016-04-22T19:12:31Z2016-04-22T18:52:09Z
<p>You might also use <a href="http://myrepos.branchable.com/">http://myrepos.branchable.com/</a> as a somewhat
more flexible alternative to submodules.</p>
<p>It's worth thinking about what would happen if you were able to check a git
repository into a git (annex) repository. A git repository contains files
like <code>.git/index</code> that are git internals, and binary files. Now what
happens if you have two checkouts of that nested git-in-git repository, and
git writes two different versions of the <code>.git/index</code> file? You'd get a
merge conflict that you have no way of resolving, involving two versions of
an internal use binary file. This is a lot worse than a merge conflict involving
some regular binary file like a jpeg, because at least with jpegs you can
look at the two versions of the file and pick the better one.</p>
<p>While git prevents checking in <code>.git</code> directories, you could technically work
around it, if you really wanted to, by eg using <code>GIT_DIR</code> to rename
the <code>.git</code> directory to something else. But it's just setting yourself up for
unresolvable merge conflicts and pain.</p>
<p>It's likewise not good to check in other version control system
directories, like <code>.svn</code>, <code>.bzr</code>, or <code>.hg</code> into git repositories or
vice-versa.</p>
<p>Sometimes people complain that the git-annex assistant should support
syncing nested git repositories, because after all other directory syncing
tools like dropbox support that. But, a little known fact about dropbox is
that it too can end up with a conflicted merge type situation, and when
this happens it will do <em>something</em> to auto-resolve it. That something
almost certianly does not include leaving the git repository what was
stored in dropbox in an ideal state. So, while people put git repos into
dropbox and get away with it, they are just being lucky to not run into the
edge cases where doing that blows up.</p>
did this todayhttp://git-annex.branchable.com/forum/n00b_question._Can_I_use_git-annex_to_manage_a_tree_that_contains_git_repos__63__/comment_4_9c6386710387f7334ea44c1de7cc8729/xloem2016-04-25T20:40:02Z2016-04-25T20:40:02Z
<p>it's interesting to find this discussion, I just finished implementing this on my system.</p>
<p>I've been storing bare repos in annex in order to back them up with the same system. I have really huge files in some of my git repos and I wanted to get those files into the annex system but still keep a record of their changes (the git history).</p>
<p>Today I removed the core.bare = true setting on the repos and instead set core.worktree = projectdir, and ran git checkout in projectdir. I have the index file in .gitignore, so there won't be that weird unresolvable conflict. Now all my bloated git history is stored in the annex, and I can still work with it in the annexed checkout.</p>
<p>I was thinking I'd do this again with the root of the repository when the annex grows too large, to back up the old history in a connected way.</p>