今天在合并項目代碼時,.DS_Store和.xcuserstate文件沖突無法合并休里。需要移除忽略.DS_Store和.xcuserstate文件蛆挫。
1.打開終端,切換到項目路徑, 輸入 cd 項目路徑 ,
2.創(chuàng)建.gitignore文件,此文件可創(chuàng)建需要忽略的類型文件,執(zhí)行 ?vim .gitignore,輸入
.DS_Store*.xcuserstate
按ESC妙黍,在輸入:wq保存退出
3.在命令行輸入
git rm --cached *xcuserstate
git rm ---cached .DS_Store
按:再按wq退出編輯
4.執(zhí)行
$ git add .gitignore
$ git commit -m "Remove and ignore .xcuserstate and .DS_Store files."
添加并提交文件
5.打開項目悴侵,解決其他項目文件沖突,合并代碼
合并時可能會報
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.
執(zhí)行
git add .
git commit -a -m "add ."
git pull ?origin master
git merge origin/master
成功解決!
參考資料:
https://stackoverflow.com/questions/21868857/removing-xcuserstate-and-ds-store-files-from-git
http://www.reibang.com/p/4f69c79b295f