我对git还比较新,希望我没有做什么很愚蠢的事情。我一直没有使用Git中忽略文件的方法,最终已经受够了不小心将操作系统文件添加到我的存储库中。
我有一个新的git存储库,其git status
为:
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .DS_Store
# README.markdown
nothing added to commit but untracked files present (use "git add" to track)
运行
git add .
,然后运行git status
会产生以下结果:# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .DS_Store
# new file: README.markdown
#
运行
git config -l
命令会显示以下内容:core.excludesfile=/Users/Chris/.gitignore
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
/Users/Chris/.gitignore
文件的内容如下:
# 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
.DS_Store
。虽然这并没有什么意义,但我还没看到过这些文件。 - Michael Krelin - hacker.DS_Store?
好多了;-) - Michael Krelin - hacker