我使用 composer.phar.

这会在 publichtml/app/code/community (例如)有一个目标 vendor/themodule....

在我的 .gitignore 我排除了供应商目录 - 但是链接当然仍会最终进入git。

有吗 简单的 自动排除这些链接的方法? (除了手动将所有内容添加到.gitignore之外)

我不得不说我有一些 require-dev 最终不应该在最终服务器上的模块 - 因此,拥有这些链接至少不会那么好。

有帮助吗?

解决方案

我想出的最好的是在作曲家安装/更新之后运行此操作

$ find * -type l -not -exec grep -q "^{}$" .gitignore \; -print >> .gitignore

该命令应在GIT根目录中运行。它将所有符号链接添加到不在那里的.gitignore文件中。

其他提示

此方法仅添加未跟踪的符号链接,因此可以重复重复,而无需添加重复的条目,在子模块中或已被忽略或故意跟踪的符号链接。

for f in $(git status --porcelain | grep '^??' | sed 's/^?? //'); do
    test -L "$f" && echo $f >> .gitignore;
    test -d "$f" && echo $f\* >> .gitignore;
done

如今,在作曲家安装程序中有一个选项。只需设置额外的 https://github.com/magento-hackathon/magento-composer-installer/blob/master/readme.md#auto-add-files-to-gitignore

@colinm和@vinai的组合解决方案对我有用

for f in $(git status --porcelain | grep '^??' | sed 's/^?? //'); do
    if test -L "$f"
    then
        test -L "$f" && echo $f >> .gitignore;
    elif test -d "$f"
    then
        find ${f%/} -type l -not -exec grep -q "^{}$" .gitignore \; -print >> .gitignore
    fi
done
许可以下: CC-BY-SA归因
scroll top