Symbolic links are just files containing symbolic pointer to other files. Git commits the contents of the symbolic link into its repo and clone and pull will recreate those symbolic links.
Symbolic links could contain absolute or relative paths to a file. A relative path starts at the directory where the link is located. So, imagine this directory/file struct
a -
|- b -
|- hello.js
|- hello.js
you want to replace one of the files with a relative symbolic link to the another one.
Supposedly you decide that your real file is in a/hello.js
and your link will be in a/b/hello.js
. So, you would need to do 2 things in a linux-type shell:
rm a/b/hello.js # you need to replace it with a symbolic link
ln -s ../hello.js a/b/hello.js
in the dos shell
mklink a\b\hello.js ..\hello.js
Now the file a/b/hello.js
will contain text ../hello.js
. The file system will use the text to find the real file in the parent directory a/b
.
Git will save the link pointer and when you clone the repo, the file system will see the the symbolic link to ..\hello.js
If you decide to use another file as a symbolic link, you can do
ln -s b/hello.js hello.js
This way b/hello.js
will be a relative symbolic link and will be substituted in the path instead of a/hello.js
Also, a symbolic link can have a name different from the original file. A symbolic link can point to another symbolic link as well in a chain-like sequence.
Hope it helps you with your problem.
relative
symbolic links, e.g.,ln -s ../hello.js hello.js
. This way it will work in any clone as well. – Sequestrate