使用git合并分支时.DS_Store和.xcuserstate文件冲突

来源:互联网 发布:澳洲股市行情软件app 编辑:程序博客网 时间:2024/06/05 09:20

今天在合并项目代码时,.DS_Store和.xcuserstate文件冲突无法合并。需要移除忽略.DS_Store和.xcuserstate文件。

1.打开终端,切换到项目路径, 输入 cd 项目路径 ,

2.创建.gitignore文件,此文件可创建需要忽略的类型文件,执行  vim .gitignore,输入

.DS_Store*.xcuserstate
按ESC,在输入:wq保存退出

3.在命令行输入

git rm --cached *xcuserstategit rm ---cached .DS_Store

按:再按wq退出编辑

4.执行

$ 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.

执行

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.jianshu.com/p/4f69c79b295f






原创粉丝点击