Store files from a Git repository?
我该如何从Git存储库中删除那些烦人的Mac OS X .DS_Store
文件?
Remove existing files from the repository:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Add the line
.DS_Store
to the file .gitignore
, which can be found at the top level of your repository (or created if it isn't there already). You can do this easily with this command in the top directory
echo .DS_Store >> .gitignore
Then
git add .gitignore
git commit -m '.DS_Store banished!'
将benzado和webmat的答案结合起来,使用git rm
更新,而不是对不在回购目录中的文件进行失败,并使其可以一般粘贴到任何用户:
# remove any existing files from the repo, skipping over ones not in repo
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
# specify a global exclusion list
git config --global core.excludesfile ~/.gitignore
# adding .DS_Store to that list
echo .DS_Store >> ~/.gitignore
The best solution to tackle this issue is to Globally ignore these files from all the git repos on your system. This can be done by creating a global gitignore file like:
vi ~/.gitignore_global
Adding Rules for ignoring files like:
# 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
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Now, add this file to your global git config:
git config --global core.excludesfile ~/.gitignore_global
Edit:
Removed Icons as they might need to be committed as application assets.
链接地址: http://www.djcxy.com/p/54910.html上一篇: 如何打印从动态库导出的符号列表
下一篇: 存储来自Git存储库的文件?