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.


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.)

Answered By – torek

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published