#### 全局忽略. 忽略除 /Data/index.html 以外的所有其他 Data下的文件
~~~
/Data/*
!/Data/index.html
~~~
#### 单个工程设置排除文件,在工程目录下找到.git/info/exclude,把要排除的文件写进去:
~~~
*.class
*.apk
bin/
gen/
.settings/
proguard/
~~~
>无论是全局忽略还是单个工程忽略,对已经在代码库中的文件没有效果. 对已经在代码库中的文件忽略,提供下面的方法.
#### git忽略已经被提交的文件
[参考](http://qlqllu.iteye.com/blog/1966119)
[参考1](https://my.oschina.net/zmf/blog/501207)
文件在仓库中存在,但是不想每次修改后就提交(这样的文件一般是与本机开发环境相关的文件),可以这样操作:
1. 打开.git/config文件
2. 增加
~~~
[alias]
ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged
ignored = !git ls-files -v | grep "^[[:lower:]]"
~~~
3. 运行 `git ignore filename`
例:`git ignore Application/Home/Conf/log_config.php`
这样,再次提交时这个文件的修改就不会被提交。如果需要再次提交这个文件,运行
`git unignore filename`
查看所有被忽略的已经提交的文件[参考2](http://stackoverflow.com/questions/17195861/undo-git-update-index-assume-unchanged-file)
~~~
git ls-files -v|grep '^h'
~~~
或
~~~
git ls-files -v|grep '^h'|cut -c3-
~~~
>这种操作一般用于临时性的文件忽略.避免过多使用