0

I have a root git directory. I would like to put under the root directory another independent git repository as subdirectory.

I am using repo so I can't use submoudles. I thought to make a subdirectory symbolic linked to a far stand alone directory. The far outside directory will contain the new git repository.

I saw there is another option Detach (move) subdirectory into separate Git repository using git subtree.

  1. Can I use it when working with the repo tool?
  2. Is it better to use subtree than the symbolic link solution?
Community
  • 1
  • 1
0x90
  • 39,472
  • 36
  • 165
  • 245

1 Answers1

0

subtree, unlike submodule, doesn't require any additional steps to get the source code of a subdirectory it manages. That is, simple git clone or git checkout will "deliver" all of the contents of a directory managed with subtree. Therefore any tool which works with Git should be fine with subtrees, including Repo (although I didn't personally try it with subtrees exactly).

Note, however, that to update a directory managed with a subtree, one still needs to do it manually. That is, the commit to whcih a subtree points to is stored into the Git repository itself, and can only be updated manually with git subtree merge or git subtree pull again.

Think of a subtree-managed directory as if it is any other directory in the repository. The only thing subtree adds - is that it allows merging other branches (including remote ones) into a specific prefix (that is into a subdirectory). And does it very well.

Using synlinks to external repositories may not work - see another SO answer on this - https://stackoverflow.com/a/1507967/302343.

Community
  • 1
  • 1
Tim
  • 12,318
  • 7
  • 50
  • 72