Git 忽略上传文件设置 .gitignore exclude
1、项目根目录下创建.gitignore
vi .gitignore #输入需要忽略的文件,支持正则表达式, *.o *.exe
*.pyc
可以用git status来检查是否生效
未添加文件前: MacPro:python apple$ git status Untracked files: (use "git add <file>..." to include in what will be committed) xiaobai_kindle/text_create.pyc 添加文件后: MacPro:python apple$ git status Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore
.gitignore文件会纳入git管理,会上传到库中。
2、全局的 .gitignore
#在用户目录下创建.gitignore_global文件 git config --global core.excludesfile ~/.gitignore_global
3、exclude文件(.git/info/exclude)
.gitignore 文件本身会push到库中去,保存的是公共的需要排除的文件。
exclude 是自己本地忽略的设置,多人开发项目时不会影响到其他人,也不会提交到库中去。
vi .git/info/exclude
#写入要忽略的文件
*.o
4、常用ignore rules:
# Compiled source # ################### *.com *.class *.dll *.exe *.o *.so # Packages # ############ # it's better to unpack these files and commit the raw source # git has its own built in compression methods *.7z *.dmg *.gz *.iso *.jar *.rar *.tar *.zip # Logs and databases # ###################### *.log *.sql *.sqlite # OS generated files # ###################### .DS_Store* ehthumbs.db Icon? Thumbs.db
参考:
http://blog.csdn.net/vic___/article/details/9446729