Make a folder both a symlink and a git submodule

1.1k views Asked by At

This my project structure in a nutshell:

 + A
 | + some content
 |
 + B
   + A

I want in my main git repo a submodule in B that points to A. But since the A project contains the main method, I want to be able to quickly test before committing, so I'd like a symlink (or rather a mklink since I'm on windows) that points to A so it gets updated without committing.

1

There are 1 answers

0
VonC On

The problem is that A doesn't have just "some content".
It also has a .git subfolder in it, which a submodule does not.

If you can, use git worktree in order to checkout a branch in a separate folder (than the original A cloned folder)

Then you can try and use a symlink from B subfolder to A, after adding A as a submodule in B.
Note: since Windows 10 build 14972 (Dec. 2016), symlinks (mklink) can be created without needing to elevate the console as administrator.


A better approach is described in "Git: Possible to use same submodule working copy by multiple projects?".