git - 忽略同一根目录中的多个文件夹

标签 git gitignore

我在 .gitignore 文件中偶然发现了这条规则

src/ms.net/CrmPackageAll/*.suo[!!-~]*.user[!!-~]bin[!!-~]obj

看起来像是忽略的意思

-- files ending with .suo and .user
-- folders bin and obj

但是当我输入 git status 时,它仍然显示未跟踪文件中的 bin 和 obj 文件夹,什么是 [!!-~]?找不到任何相关文档以及如何在单个规则中忽略 bin 和 obj 文件夹?

最佳答案

我在 gitignore man page 中没有看到该格式.

如果您需要忽略:

  • .suo.user 结尾的文件
  • 文件夹binobj

您的.gitignore将是:

*.suo
*.user
bin/
obj/

如果 git 状态仍然显示这些文件/文件夹,则意味着它们已被跟踪。
您需要先删除它们:

例如:

git rm --cached -r bin/
git commit -m "remove bin"

然后 git status 将不再列出该 bin/ 文件夹。

关于git - 忽略同一根目录中的多个文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48017894/

相关文章:

windows - Windows 上的 Git, "Out of memory - malloc failed"

linux - Github 不响应 SSH

git 提交一次并从那时起忽略

regex - Git 忽略 : How to match one or more digits

git - .gitignore 中多个文件扩展名的简写

linux - 回到我工作目录的历史——git、bash

linux - Gitolite访问修复

svn - 将 SVN 子目录转换为 Git

git - .gitignore 的功能可以避免推送 API key ?

git - 是否可以自定义 .gitignore?只读权限?