[英]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
根據您的問題,文件已經提交。 Git將繼續報告對已提交的被忽略文件的更改。 你應該通過這樣做刪除你想要忽略的文件: https : //stackoverflow.com/a/1143800/556085
具體來說:git rm --cached mylogfile.log對於一個目錄:git rm --cached -r mydirectory
要忽略元數據文件夾,請使用**/metadata/*
。 (確保使用git版本1.8.2或更高版本)
另外,你錯誤輸入了.gitignore
。 (將文件名從,gitignore
為.gitignore
)
你也可以看看這個發電機 - > gitignore.io
為了防止./metadata/
文件夾中的所有內容被git“看到”,請添加
/metadata/
到您的.gitignore
文件。
您似乎已將文件命名為,gitignore
而不是.gitignore
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.