Search code examples
gitsymlink

git commit symlink as a regular file


Suppose I have a file fname which is a symlink to a file from some other repository/project, say ../../proj2/fname.

Is there a way to add/commit fname as a regular file?

It seems that, by default, git gives the file mode 120000 and sets the path to the linked file as the blob content.

I know this because git ls-tree shows mode 120000 for the file, and git cat-file -p shows ../../proj2/fname as the blob's content.


Solution

  • Nope, Git knows it's a symlink. It'd be kind of dangerous for Git to pretend otherwise, since it would then end up writing to files outside the repo. Tracking it as a symlink is exactly the intended behavior.