How can I add symlink to file to gitlab repository?
Every time I run a pipeline from gitlab, the local symlink gets destroyed.
Any suggestions on how to create a symlink for a folder which resides inside of gitlab repo would be great.
To find out, first, make a symbolic link:
$ ln -s /Path/referenced/by/symlink symlink
Git doesn't know about this file yet. git ls-files lets you inspect your index (-s prints stat-like output):
$ git ls-files -s ./symlink
$
Now, add the contents of the symbolic link to the Git object store by adding it to the index. When you add a file to the index, Git stores its contents in the Git object store.
$ git add ./symlink
So, what was added?
$ git ls-files -s ./symlink
120000 1596f9db1b9610f238b78dd168ae33faa2dec15c 0 symlink
$
The hash is a reference to the packed object that was created in the Git object store. You can examine this object if you look in .git/objects/15/96f9db1b9610f238b78dd168ae33faa2dec15c.
The 120000 is the file mode. It would be something like 100644 for a regular file and is the mode special for links. From man git-config:
core.symlinks
If false, symbolic links are checked out as small plain files that contain the link text. git-update-index(1) and git-add(1) will not change the recorded type to regular file.
Use git cat-file -p
to pretty-print the contents:
$ git cat-file -p 1596f9db1
/Path/referenced/by/symlink
So, that's what Git does to a symbolic link: when you git checkout the symbolic link, you either get a text file with a reference to a full filesystem path, or a symlink, depending on configuration. The data referenced by the symlink is not stored in the repository.