Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: committing a symlink to a folder

Tags:

git

When adding to the index a symlink to a directory, I get the following error message:

fatal: pathspec 'XXX' did not match any files

The file is there, and it is indeed a symlink, even to a directory inside the repository in fact.

like image 491
charles Avatar asked May 23 '12 02:05

charles


People also ask

Can you Git commit symlinks?

Note that even after committing and pushing into Git, the symlinks still work fine. However, after some branch switches and code merges, the symlinks become actual text files with the link target as the contents.

Can you make a symbolic link to a directory?

A symbolic link, also known as a soft link or symlink, is a special file pointing to another file or directory using an absolute or relative path. Symbolic links are similar to shortcuts in Windows and are useful when you need quick access to files or folders with long paths.

Does Git keep symlinks?

Git just stores the contents of the link (i.e. the aforementioned path of the file system object that it links to) in a 'blob' just like it would for any other file. It then stores the name, mode and type (including the fact that it is a symlink) in the tree object that represents its containing directory.

How can we create a symbolic click link to file?

Go to the folder where you want the symlink to appear, right-click it, then select “Drop As -> Symbolic Link.”


1 Answers

At least on my machine (Mac OS 10.7), the solution was to have the symlink actually point to some real content. In other words, the way the symlink was setup in the repository was that it was 'broken' (this was intentional: during the build process, that symlink would eventually become active in the final product). So I created a directory where the symlink was expecting it, was able to commit without an error, and then could delete that directory.

like image 71
charles Avatar answered Oct 05 '22 12:10

charles