为什么我的 .gitignore 文件没有忽略特定文件?
Why is my .gitignore file not ignoring specific files?
为什么我的 .gitignore 文件没有忽略特定文件?
我需要忽略任何以 .metadata/.
开头的文件
我创建了一个 git 文件( .gitignore ):
Git ignore file
我在忽略文件中添加了以下文本:
.metadata/.*
但是我的文件似乎仍然以红色显示文件:
± |master ↑8 U:44 ?:22 ✗| → git status
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .metadata/.log
modified: .metadata/.mylyn/.tasks.xml.zip
modified: .metadata/.mylyn/tasks.xml.zip
modified: .metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json
modified: .metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties
为了防止 ./metadata/
文件夹中的所有内容被 git "seen",添加
/metadata/
到您的 .gitignore
文件。
您似乎将文件命名为 ,gitignore
而不是 .gitignore
。
根据您的问题,文件已经提交。
Git 将继续报告对已提交的已忽略文件的更改。在你应该通过这样做从你的 git 仓库中删除你希望忽略的文件:
特别是:git rm --cached mylogfile.log 对于目录:git rm --cached -r mydirectory
要忽略 元数据 文件夹,请使用 **/metadata/*
。 (确保使用 git 或更高版本的 1.8.2)
此外,您打错了 .gitignore
。 (将文件名从 ,gitignore
更改为 .gitignore
)
您也可以查看此生成器 -> gitignore.io
为什么我的 .gitignore 文件没有忽略特定文件?
我需要忽略任何以 .metadata/.
开头的文件我创建了一个 git 文件( .gitignore ): Git ignore file
我在忽略文件中添加了以下文本:
.metadata/.*
但是我的文件似乎仍然以红色显示文件:
± |master ↑8 U:44 ?:22 ✗| → git status
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .metadata/.log
modified: .metadata/.mylyn/.tasks.xml.zip
modified: .metadata/.mylyn/tasks.xml.zip
modified: .metadata/.plugins/com.genuitec.eclipse.devstyle/recent.json
modified: .metadata/.plugins/com.genuitec.eclipse.monitor/myeclipse-usage.properties
为了防止 ./metadata/
文件夹中的所有内容被 git "seen",添加
/metadata/
到您的 .gitignore
文件。
您似乎将文件命名为 ,gitignore
而不是 .gitignore
。
根据您的问题,文件已经提交。 Git 将继续报告对已提交的已忽略文件的更改。在你应该通过这样做从你的 git 仓库中删除你希望忽略的文件:
特别是:git rm --cached mylogfile.log 对于目录:git rm --cached -r mydirectory
要忽略 元数据 文件夹,请使用 **/metadata/*
。 (确保使用 git 或更高版本的 1.8.2)
此外,您打错了 .gitignore
。 (将文件名从 ,gitignore
更改为 .gitignore
)
您也可以查看此生成器 -> gitignore.io