Search code examples
gitgit-submodules

How to specify parent directory as submodule path


How (if possible) to have a submodule path as the parent directory such that a git submodule update --init --recursive will clone the submodule in the parent directory of the current repository?

I tried doing that by creating a submodule in a nested folder in a regular way, then manually modifying .git/config and .gitmodules to have path = ../ and modifying .git/modules/mymodule/config to have worktree = ../../../../ but no luck.

I essentially want to let git submodule update --init --recrusive clone a repository in the parent directory.


Solution

  • You can't. Git won't let you create stuff outside the working tree, because doing so would be a security violation. (Imagine for instance one that creates and fills in ../../../../../../../../../../etc/passwd.)