美文网首页
(.DS_Store)避免多人提交代码到GitHub上起冲突

(.DS_Store)避免多人提交代码到GitHub上起冲突

作者: 程旭媛 | 来源:发表于2015-12-03 14:50 被阅读15139次

https://www.gitignore.io/gitignore的生成网址

在多人合作的项目里,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文件。

相关文章

  • .DS_Store _&_ .gitignore

    (.DS_Store)避免多人提交代码到GitHub上起冲突http://www.jianshu.com/p/4f...

  • (.DS_Store)避免多人提交代码到GitHub上起冲突

    https://www.gitignore.io/gitignore的生成网址 在多人合作的项目里,git pul...

  • github

    如何使用Git上传项目代码到github 提交本地代码到github github 的命令 如何提交changes...

  • 忽略.DS_store文件

    最近每次提交代码的时候都有有提示一个.DS_store,而且有时候下拉代码的时候也是这个冲突 搜索了资料之后发现需...

  • 提交代码到GitHub

    1. git init 2. git add . 3. git commit -m”第N次提交(随意写)" 4. ...

  • 终端使用:git

    1、使用git提交代码忽略的文件:.DS_Store、UserInterfaceState.xcuserstate...

  • cocoapod添加仓库

    1、提交代码到github 1)在github添加远程仓库2)将本地代码提交到远程仓库git remote add...

  • 代码优化基础

    统一格式化 多人合作开发项目时,统一的代码格式可以避免代码提交、合并时很多不必要的冲突。 代码格式风格要使用IDE...

  • Git提交规范:commitlint + husky

    提交代码的时候,能够根据自定义的提交信息、代码规范进行自动校验,避免多人协作开发时提交代码信息不准确或者代码格式的...

  • 项目发版冲突解决实例操作

    问题:服务器代码与本地库代码冲突,提交到服务器了,后面也有更多人更新这个冲突代码,如何解决。 解决流程:

网友评论

      本文标题:(.DS_Store)避免多人提交代码到GitHub上起冲突

      本文链接:https://www.haomeiwen.com/subject/rslshttx.html