8

解决gitignore忽略某个文件无效问题

 2 years ago
source link: https://www.iplayio.cn/post/971158
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

原文地址:解决gitignore忽略某个文件无效问题

解决gitignore忽略某个文件无效问题

发生gitignore忽略某个文件无效问题原因

确保您.gitignore位于工作目录的根目录中,并在该目录中运行git status并从状态输出复制文件的路径并将其粘贴到.gitignore.

如果这不起作用,则很可能您的文件已被 Git 跟踪。您可以通过 的输出确认这一点git status。如果该文件未列在“未跟踪的文件”部分中,则它已被 Git 跟踪,它将忽略.gitignore文件中的规则。

在 Git 中忽略文件的原因是它们不会被添加到存储库中。如果您之前添加了要忽略的文件,则 Git 将跟踪该文件并跳过匹配它的忽略规则。Git 这样做是因为该文件已经是存储库的一部分。

为了实际忽略该文件,您必须取消跟踪它并将其从存储库中删除。您可以使用git rm --cached sites/default/settings.php. 这会从存储库中删除文件而不实际删除文件(这就是这样--cached做的)。提交该更改后,该文件将从存储库中删除,忽略它应该可以正常工作。

解决gitignore忽略某个文件无效问题

1.某个文件无效

git rm --cached 包含路径文件,例如 ./app/test.php

2.多个文件

可以删除所有的git缓存,然后重新add commit。

git rm --cache .

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK