Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Git ignore symlink?

Tags:

git

I have symlinks in my project folder so that large directories of videos and images are accessible when I am running project in local dev server on my windows 10 machine.

The problem with this is that Git wont let me do "add ." because when symlinks are present it gives me this error:

error: readlink("ProjectName/SymlinkName"): Function not implemented
error: unable to index file ProjectName/SymlinkName
fatal: adding files failed

I have added the symlinks to the .gitignore but this didn't change anything.

I am cautious about making them hardlinks inside my dev project. Is this my only option?

Edit:

My gitignore looke like this:

NameOfSymlink/
AnotherSymlink/
like image 848
Guerrilla Avatar asked Nov 07 '16 07:11

Guerrilla


People also ask

Does git ignore symbolic links?

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 do I set git ignore?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Does git understand Symlinks?

Git can track symlinks as well as any other text files. After all, as the documentation says, a symbolic link is nothing but a file with special mode containing the path to the referenced file. Knowing how to handle links is the OS job.


1 Answers

Git considers symlinks to be files, not directories. You need to remove the / at the end of each .gitignore line:

NameOfSymlink
AnotherSymlink
like image 104
1615903 Avatar answered Sep 26 '22 00:09

1615903