Git学习总结(4)——我的Git忽略文件
*.bak
*.txt
*.vm
.gitignore
#svn
.svn/
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Proguard folder generated by Eclipse
proguard/
# Intellij project files
*.iml
*.ipr
*.iws
.idea/
*.bak
*.txt
*.vm
.gitignore
#svn
.svn/
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Proguard folder generated by Eclipse
proguard/
# Intellij project files
*.iml
*.ipr
*.iws
.idea/
方法一:命令方法
1.首先在仓库中创建隐藏文件“.gitignore”,选中本地仓库,右击“Git Bash Here”,然后执行如下命令:
touch .gitignore
2.用文本编辑器如editplus或notepad++输入需要忽略的文件或文件名,如下所示:
##ignore this file##
/target/
.classpath
.project
.settings
##filter databfile、sln file##
*.mdb
*.ldb
*.sln
##class file##
*.com
*.class
*.dll
*.exe
*.o
*.so
# compression file
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.via
*.tmp
*.err
# OS generated files #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
备注:
/target/ :过滤文件设置,表示过滤这个文件夹
*.mdb ,*.ldb ,*.sln 表示过滤某种类型的文件
/mtk/do.c ,/mtk/if.h 表示指定过滤某个文件下具体文件
!*.c , !/dir/subdir/ !开头表示不过滤
*.[oa] 支持通配符:过滤repo中所有以.o或者.a为扩展名的文件
该方法保证任何人都提交不了这类文件
方法二:eclipse安装git插件设置:点击“Add Pattern”添加你要过滤的文件,该方法只能保证本地提交过滤,但是提交远程仓库则不会