Git不会忽略文件(Git won't ignore files)

我有一些我希望Git忽略的日志文件。 他们全都在:

/Lead Services/logs/

在.getignore文件中,我尝试输入所有这些:

/Lead Services/logs /Lead Services/logs/ /Lead Services/logs/* /Lead Services/logs/**

我甚至试图输入特定的文件:

/Lead Services/logs/LeadAcceptance-LocalDev.txt

无论我尝试什么,这些文件都会在“更改”下的团队资源管理器中显示。 我究竟做错了什么?

I have some log files that I want Git to ignore. They are all in:

/Lead Services/logs/

In the .getignore file, I have tried entering all of these:

/Lead Services/logs /Lead Services/logs/ /Lead Services/logs/* /Lead Services/logs/**

I've even tried to enter specific files:

/Lead Services/logs/LeadAcceptance-LocalDev.txt

No matter what I try, these files keep showing up in Team Explorer under "Changes". What am I doing wrong?

最满意答案

您可以使用git rm永久排除文件。 在您的本地存储库中,执行

git rm -r --cached logs/*

然后

git add . git commit -m "Excluded logs from tracking" git push

从现在起,git将不再跟踪日志文件夹。 另外,你可以参考这个问题。

You can use git rm to exclude file from tracking permanently. In your local repository, do

git rm -r --cached logs/*

then

git add . git commit -m "Excluded logs from tracking" git push

From now on, the git won't track the logs folder, any more. Also, you may refer to this question.

更多推荐