關鍵:在項目的根目錄(跟.git文件夾所在目錄同層)創建.gitignore文件,在裏面聲明便可。
譬如我要忽略當前項下的全部dll文件,及runtime文件夾裏全部文件:
#ignore these files
*.dll
runtime/*
若是以前文件已提交過,則須要先清除原文件,針對上文作的清理以下:
$ git rm *.dll
$ git rm -r runtime
另外一種方法:修改git的全局設置,把忽略名單用於全部項目:
首先,創建一個.gitignore_global文件;
執行 $ git config --global core.excludesfile .gitignore_global
經常使用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 git