Git ignore 不会忽略 netbeans 私有文件 [英] Git ignore is not ignoring the netbeans private files
问题描述
每当我执行 git status 时,netbeans private.xml 都会遇到麻烦,我尝试在 git ignore 几种方法中添加它.但 gitignore 根本没有忽略它.
When ever I do git status, the netbeans private.xml is making trouble, I tried adding that in git ignore several ways. but the gitignore simply does not ignore it.
git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitignore
modified: nbproject/private/private.xml
...
我的 git 忽略文件是
My git ignore file is
node_modules/
dist/
*.log
nbproject/private/*
*.bak
*.orig
*~
*.log
*private.xml
都试过了nb项目/私人/*和*private.xml在同一个文件中.
Tried both nbproject/private/* and *private.xml in the same file.
推荐答案
已经被跟踪的文件不会被忽略:你需要先从索引中删除.
A file which is already tracked would not be ignored: you need to remove from the index first.
git rm --cached private.xml
git add -u .
git commit -m "Record deletion of private.xml from the index"
(--cached
选项确保文件保留在磁盘上)
(the --cached
option make sure the file remains on the disk)
然后就可以在.gitignore中添加(不需要'*')
Then you can add it in the .gitignore (no need for '*')
private.xml
注意:无论何时一个文件被忽略或不被忽略,你都可以检查哪个 .gitignore
规则适用于:
Note: whenever an file is or is not ignored, you can check out which .gitignore
rule applies with:
git check-ignore -v -- private.xml
这篇关于Git ignore 不会忽略 netbeans 私有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!