在多人合作的項目里,git pull origin master執行完之后出現以下問題:
Auto-merging .DS_Store CONFLICT (content): Merge conflict in .DS_Store Automatic merge failed;
原因是.DS_Store這樣的文件在項目提交時需要忽略掉。
忽略步驟:
1、touch .gitignore 創建一個文件,
open -e .gitignore 把配置內容粘貼上傳,然后保存。(內容是https://www.gitignore.io/gitignore網站里輸入 Mac os objective-c cocoapods xcode即可以獲取到)
git add .
git commit
然后要全局使用這個 .gitignore
$ git config --global core.excludesfile ~/.gitignore
后面跟的是 .gitignore文件位置。你可以更改。但是那個路徑下 必須存在那個配置文件。
2、手動或者命令行刪除完 .DS_Store之后,執行一下命令:
rm .DS_Store
git add .
git commit -a -m “更改內容”或者git commit -am是前者的簡寫
git pull origin master
git push origin master
執行完之后 其他同事需要合並我的代碼,如果同事有內容提交,執行一下命令:
git add .
git commit -a -m “修改的內容"
git pull origin master
git merge origin/master執行此命令之后出現以下錯誤:
error: merge is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm '
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
出現此錯誤后重新執行
git add .
git commit -a -m “ssss”
git pull origin master
git merge origin/master
然后再執行下面
git push origin master
至此GitHub上就不會再有.DS_Store了成功的表現是:本地有.DS_Store和gitignore文件就可以了,GitHub上有.gitignore 沒有 .DS_Store文件。
原文鏈接:http://www.jianshu.com/p/4f69c79b295f
著作權歸作者所有,轉載請聯系作者獲得授權,並標注“簡書作者”。