Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is pushing a symbolic link to git a bad practice?

Tags:

git

symlink

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.

like image 549
Alec Walczak Avatar asked Jun 30 '15 21:06

Alec Walczak


People also ask

Should I enable symbolic links in git?

Do not use symbolic links at all, especially not outside the repository. If you must use the same file, maybe investigate Git submodules.

Are symbolic links bad?

Symlinks are bad. They break the natural semantics of a hierarchical tree-like filesystem, and turn it into a messy half-assed graph.

Does GIT understand symlinks?

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 does Git treat symbolic links?

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.


1 Answers

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:

  • inside a repository, but with an absolute path (bad practice)
  • outside the repository with a relative or absolute path (bad practice)

"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.

like image 124
VonC Avatar answered Oct 04 '22 22:10

VonC