简体   繁体   中英

Using git submodules as junctions in Windows

If a submodule's directory is a junction (Windows), git doesn't detect it as a repository and cannot work on such submodule.

For example, imagine a repository root is in c:\src\root , and that has one submodule subrepo , that is a junction to another drive. So c:\src\root\subrepo links to d:\submodules\subrepo .

If you try any git command on c:\src\root\subrepo you will receive an error message like

$ git pull

fatal: not a git repository: d:/submodules/subrepo/../.git/modules/subrepo

How can I solve these issues?

As you see, the problem is that git resolves the junction and works on the destination directory, instead of using the original path.

To solve the junction problem with git and submodules, it is enough to make a second junction, but in reverse way, to the .git directory of the parent rep. This should be a sibling of the subrepo directory, so it can be found when constructing the ../.git/ relative path.

d:\submodules\.git ==> c:\src\root\.git
c:\src\root\subrepo ==> d:\submodules\subrepo

Note that this may be a mess if you have different set of submodules, so in this case just group them into the same directory to avoid conflicts with duplicated .git directories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM