我最近做了一個新的分支,致力於它,並切換回舊的分支。.DS_Store導致Git問題
我想看看新的分支,但我得到這個錯誤:
error: The following untracked working tree files would be overwritten by checkout:
client/.DS_Store
所以,我做了一些google搜索,並瞭解到,這些本來應該在我的.gitignore。所以我將它們添加到我的全局.gitignore中以防止將來出現此問題。但是,這並不解決我在現在的問題,這是當我使用這個命令來修正這個錯誤,因爲我已經看到了建議,這是行不通的,扔了以下錯誤:
git rm --cached client/.DS_Store
fatal: pathspec 'client/.DS_Store' did not match any files
我真的需要切換回我的其他分支!我現在該怎麼做?
編輯:我的新的全球性的.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
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
你可以試試git add。 && git stash,然後切換到另一個分支。另外,你可以複製並粘貼你的gitignore?任何時候我添加到我的gitignore的變化都反映出來。我不得不使用類似於上面的緩存刪除命令的東西,但我不必指定相關文件夾。 – adpro
工作。我能夠切換到另一個分支。謝謝! – DJG
沒問題 - 請參閱我的答案 – adpro