.gitignore 配置文件用于配置不需要加入版本管理的文件,配置好该文件可以为我们的版本管理带来很大的便利,以下是个人对于配置 .gitignore 的一些心得。
1、配置语法:
以斜杠“/”开头表示目录;
以星号“*”通配多个字符;
以问号“?”通配单个字符
以方括号“[]”包含单个字符的匹配列表;
以叹号“!”表示不忽略(跟踪)匹配到的文件或目录;
此外,git 对于 .ignore 配置文件是按行从上到下进行规则匹配的,意味着如果前面的规则匹配的范围更大,则后面的规则将不会生效;
2、示例:
(1)规则:fd1/*
说明:忽略目录 fd1 下的全部内容;注意,不管是根目录下的 /fd1/ 目录,还是某个子目录 /child/fd1/ 目录,都会被忽略;
(2)规则:/fd1/*
说明:忽略根目录下的 /fd1/ 目录的全部内容;
(3)规则:
/*
!.gitignore
!/fw/bin/
!/fw/sf/
说明:忽略全部内容,但是不忽略 .gitignore 文件、根目录下的 /fw/bin/ 和 /fw/sf/ 目录;
以下是作者在阅读Open edX开源项目时读到的.gitignore的相关配置:
# .gitignore for edx-platform.
# There's a lot here, please try to keep it organized.
### Files private to developers
requirements/private.txt
lms/envs/private.py
cms/envs/private.py
### Python artifacts
*.pyc
### Editor and IDE artifacts
*~
*.swp
*.orig
/nbproject
.idea/
.redcar/
codekit-config.json
.pycharm_helpers/
/_mac/*
/IntelliLang.xml
/conda_packages.xml
/databaseSettings.xml
/diff.xml
/debugger.xml
/editor.xml
/ide.general.xml
/inspection/Default.xml
/other.xml
/packages.xml
/web-browsers.xml
### NFS artifacts
.nfs*
### OS X artifacts
*.DS_Store
.AppleDouble
:2e_*
:2e#
### Internationalization artifacts
*.mo
*.po
*.prob
*.dup
!django.po
!django.mo
!djangojs.po
!djangojs.mo
conf/locale/en/LC_MESSAGES/*.mo
conf/locale/fake*/LC_MESSAGES/*.po
conf/locale/fake*/LC_MESSAGES/*.mo
# this was a mistake in i18n_tools, now fixed.
conf/locale/messages.mo
### Testing artifacts
.testids/
.noseids
nosetests.xml
.coverage
.coverage.*
coverage.xml
cover/
cover_html/
reports/
jscover.log
jscover.log.*
.tddium*
common/test/data/test_unicode/static/
test_root/courses/
django-pyfs
### Installation artifacts
*.egg-info
.pip_download_cache/
.prereqs_cache
.vagrant/
node_modules
bin/
### Static assets pipeline artifacts
*.scssc
lms/static/css/
lms/static/certificates/css/
cms/static/css/
common/static/common/js/vendor/
### Styling generated from templates
lms/static/sass/*.css
lms/static/sass/*.css.map
lms/static/certificates/sass/*.css
lms/static/themed_sass/
cms/static/css/
cms/static/sass/*.css
cms/static/sass/*.css.map
cms/static/themed_sass/
themes/**/css/*.css
themes/**/css/discussion/*.css
### Logging artifacts
log/
logs
chromedriver.log
ghostdriver.log
### Celery artifacts ###
celerybeat-schedule
### Unknown artifacts
database.sqlite
courseware/static/js/mathjax/*
flushdb.sh
build
/src/
\#*\#
.env/
lms/lib/comment_client/python
autodeploy.properties
.ws_migrations_complete
dist
来源:oschina
链接:https://my.oschina.net/u/2772739/blog/736527