如何让 Git 忽略符号链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40460216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:24:28  来源:igfitidea点击:

How do I make Git ignore symlink?

git

提问by Guerrilla

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.

我的项目文件夹中有符号链接,因此当我在 Windows 10 机器上的本地开发服务器中运行项目时,可以访问大型视频和图像目录。

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

问题在于 Git 不会让我做“添加”。因为当存在符号链接时,它会给我这个错误:

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.

我已将符号链接添加到 .gitignore 但这并没有改变任何东西。

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

我对将它们设置为我的开发项目中的硬链接持谨慎态度。这是我唯一的选择吗?

Edit:

编辑:

My gitignore looke like this:

我的 gitignore 看起来像这样:

NameOfSymlink/
AnotherSymlink/

回答by 1615903

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

Git 将符号链接视为文件,而不是目录。您需要删除/每个 .gitignore 行末尾的 :

NameOfSymlink
AnotherSymlink