2011-04-07 116 views
8

我對git相當陌生,希望我不會做一些非常愚蠢的事情。我一直生活在沒有忽略Git中的文件的方式中,並最終無意中將OS文件添加到我的存儲庫中。Git無法忽略在全局忽略中定義的.DS_Store

我有一個新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是:在您的全球.gitignore.DS_Store

# 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 

回答

6

嘗試刪除問號?

+0

非常感謝!這工作正常。我唯一的問題是爲什麼在那裏的問號?這是一個隨git一起提供的默認忽略文件。我認爲?是語法的一部分。 – 2011-04-07 11:46:06

+0

我不知道;-)問號意味着任何字符,所以它可能會覆蓋像.DS_Store1,.DS_Store2等東西。 – 2011-04-07 12:03:05

+0

這是有道理的,所以問號意味着一個字符是必需的,因此不會匹配.DS_Store - 很奇怪。 – 2011-04-09 08:37:07