Git添加。忽略.gitignore

时间:2013-11-11 14:42:28

标签: git

$ git --version:  
git version 1.7.9.5

$ cat /etc/issue:  
Ubuntu 12.04.3 LTS \n \l

$cat .gitignore  
**/._*  
**/*.swp  
**/.DS_Store  
log/  
bak/  

$ git status  
On branch 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:   html/conf/._conf.php  
modified:   html/conf/conf.php  

no changes added to commit (use "git add" and/or "git commit -a")  

如上所示,我在.gitignore中包含了** / ._ * 我首先创建了.gitignore,然后是“git init”,最后是“git add”。我提交了所有内容然后更改了html / conf / conf.php。正如您在“git status”的输出中所看到的,不会忽略._conf.php。这里的任何人都可以帮助我吗?我读了这么多教程,但显然我错过了一些东西。

“git add”。忽略忽略列表?如果是这样,我该怎么办才能避免这种情况?正确忽略与* /._ 匹配的新创建文件。

尝试“git update-index --assume-unchanged ** / ._ *”会导致
致命:无法标记文件doku /._ blabla.txt

我的想法已经不多了......

提前致谢!

1 个答案:

答案 0 :(得分:2)

.gitignore仅考虑新文件。

如果您的文件已被Git跟踪,然后进行了修改,则应使用git add .进行更改。

您可以使用以下方法将这些文件的状态设置为“假设不变”:

git update-index --assume-unchanged <file>

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

相关问题