I'm unsure of whether or not pushing symbolic links to a git repo is a bad practice or not. Is there any risk or bad reason to do so?
I haven't seen a good answer. If anyone has a good resource or explanation please share.
Do not use symbolic links at all, especially not outside the repository. If you must use the same file, maybe investigate Git submodules.
Symlinks are bad. They break the natural semantics of a hierarchical tree-like filesystem, and turn it into a messy half-assed graph.
Git does not follow symbolic links when accessing a .gitignore file in the working tree. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem.
How Git deals with symlinks is defined in the git config core. symlinks . If false, symbolic links are checked out as small plain files that contain the link text. Otherwise, Git just stores the contents of the link (i.e., the path of the file system) in a 'blob' just like it would for a normal file.
As long as the symlink references a resource within the same repository, as a relative path, it should be OK (especially now that symlinks are supported on Windows, and no longer require privilege elevation)
The following two cases would not work though, when that same symlink references a resource:
"bad practice" because :Any clone of the repository in a different machine/patform/OS would not be able to access/use those paths.
After that, it depends where the repo (with its symlink) is used.
I mentioned before in "How to add symlink file to a gitlab repo" that a symlink would make a GitLab pipeline fail.
=> "bad practice": the environment where such a repository would be used would fail to run its content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With