Last active
August 29, 2015 14:07
-
-
Save Winiex/3a2daad31e513d8e1c8b to your computer and use it in GitHub Desktop.
自动获取适合于相关语言、IDE 环境的 .gitignore 的脚本。基于 https://www.gitignore.io/ 。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git-ignore-io() { | |
curl https://www.gitignore.io/api/$@ ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
将 git-ignore-io.sh 中的内容加入你自己的 .bashrc 中,重新打开 terminal 后,即可使用 git-ignore-io 命令了。 | |
例如,我希望获取 python 语言项目的 .gitignore: | |
git-igtnore-io python | |
于是就有输出: | |
# Created by https://www.gitignore.io | |
### Python ### | |
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
# C extensions | |
*.so | |
# Distribution / packaging | |
.Python | |
env/ | |
build/ | |
develop-eggs/ | |
dist/ | |
downloads/ | |
eggs/ | |
lib/ | |
lib64/ | |
parts/ | |
sdist/ | |
var/ | |
*.egg-info/ | |
.installed.cfg | |
*.egg | |
# PyInstaller | |
# Usually these files are written by a python script from a template | |
# before PyInstaller builds the exe, so as to inject date/other infos into it. | |
*.manifest | |
*.spec | |
# Installer logs | |
pip-log.txt | |
pip-delete-this-directory.txt | |
# Unit test / coverage reports | |
htmlcov/ | |
.tox/ | |
.coverage | |
.cache | |
nosetests.xml | |
coverage.xml | |
# Translations | |
*.mo | |
*.pot | |
# Django stuff: | |
*.log | |
# Sphinx documentation | |
docs/_build/ | |
# PyBuilder | |
target/ | |
当然,我们也可以直接将输出内容重定向到 .gitignore 文件中: | |
git-igtnore-io python > .gitignore | |
其它语言、IDE 也是被支持的,只需要把 python 改成其名字即可: | |
git-ignore-io xcode | |
则有输出: | |
# Created by https://www.gitignore.io | |
### Xcode ### | |
build/ | |
*.pbxuser | |
!default.pbxuser | |
*.mode1v3 | |
!default.mode1v3 | |
*.mode2v3 | |
!default.mode2v3 | |
*.perspectivev3 | |
!default.perspectivev3 | |
xcuserdata | |
*.xccheckout | |
*.moved-aside | |
DerivedData | |
*.xcuserstate | |
如果希望将两种 ignore 叠加到一个文件中,可以这样: | |
git-ignore-io "objective-c" >> .gitignore | |
git-ignore-io "xcode" >> .gitignore | |
还可以这样: | |
git-ignore-io "objective-c,xcode" > .gitignore | |
该命令需要在有网络的情况下使用。背后使用的服务是 https://www.gitignore.io/。 | |
原始命令发现于 http://alias.sh/gitignoreio,但是该命令已经过时,所以我做出了修正。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment