git - 将忽略的文件保留在 git status 之外

标签 git gitignore

我想阻止 Git 在 git status 中显示被忽略的文件,因为在 Changed but not updated 文件列表中有大量的文档和配置文件,呈现列表有一半没用。

Git 显示这些文件正常吗?

我将忽略信息放在 Git 存储库根目录的 .gitignore 文件中,使用 git add 时不会添加它们。 但看起来它们也没有完全被忽略,因为它们出现在上述列表中并且出现在 git ls-files --others -i --exclude-standard。只有与 ~/.gitignore 中的模式匹配的文件才会显示在那里。

会不会是因为我之前没有忽略它们,所以至少提交了一次?

最佳答案

我发现 in this post , .gitignore 仅适用于未跟踪的文件。如果您将文件添加到存储库,您可以:

git update-index --assume-unchanged <file>

或通过

从存储库中删除它们
git rm --cached <file>

编辑

This article也说明了这一点

关于git - 将忽略的文件保留在 git status 之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1818895/

相关文章:

github 新仓库 .gitignore CSharp 丢失

git - .gitignore 带有通配符的文件名

git - SSL 证书 : Invalid certificate chain

git - `git reset --hard` 也重置被忽略的文件?

ruby - 混帐,Heroku : pre-receive hook declined

rust - 如何忽略 .gitignore 中的 Rust 可执行文件?

git - 为什么不 gitignore .gitignore?

git - git rebase 在哪里修改

Git Pull - 一切都是最新的,但不是

git - 您应该将 .gitignore 提交到 Git 存储库中吗?