I feel like I'm doing something wrong here (architecture-wise I know I am, but this is a simple project).
There are two ("three") sub-projects, living in the same folder (proj
):
- An Angular frontend (
proj/fe
) - A Typescript (node.js) based backend (
proj/lambda
) - A shared "domain" directory that contains the DTOs (
proj/domain
)
From what I understand, in an ideal world, this would be three separate repos, with #3 being a git submodule of #1 and #2.
But this is a tiny project, and I am not in an ideal world, so I need to keep everything in the same git repo.
The current setup is that the "domain" directory (sub-project #3) is presented to both #1 and #2 via symlinks; i.e. proj/fe/src/app/domain
and proj/lambda/code/domain
both point to proj/domain
.
Git doesn't seem to handle this scenario very well out of the box.
Is there an option or flag (or a better method -- without resolving to using mutliple repos) that I can utilize here?
CodePudding user response:
git
knows how to store and checkout symlinks, the thing is it stores the exact path you provided for your symlink.
(do double check if you are running Windows though)
Your setup should work if you provide relative paths for your symlinks (and if these path do not escape the repo) :
cd proj/
ln -nsf ../../../domain fe/src/app/domain
ln -nsf ../../domain lambda/code/domain
# on any checkout: the symlinks will point to that directory, two or
# three levels higher than current directory
If you used absolute paths instead:
ln -nsf /path/to/proj/domain fe/src/app/domain
ln -nsf /path/to/proj/domain lambda/code/domain
The checked out symlink will point to /path/to/proj/domain
-- which is not what you want on a system other than your dev laptop.