1
$ 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

我的想法不多了...

提前致谢!

4

1 回答 1

2

.gitignore仅考虑新文件。

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

您可以使用以下命令将这些文件的状态设置为“假定未更改”:

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

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

于 2013-11-11T14:49:45.107 回答