(.DS_Store)避免多人提交代码到GitHub上起冲突
2016-04-18 19:59
501 查看
在多人合作的项目里,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
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
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
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
相关文章推荐
- Spring MVC 中 HandlerInterceptorAdapter的使用
- Java中HashMap详解
- javaDAY5
- 个人对设计模式的理解-->建造者模式
- HashMapUtil java项目中缓存的使用
- 用Java 编一段代码,实现在控制台输入一组数字后,排序后在控制台输出
- struts1.0 struts标签
- java中商业数据计算时用到的类BigDecimal和DecimalFormat
- 1---------java调用NLPIR(ICTCLAS2016)实现分词功能
- Configuration of GitHub in webstorm
- 接口与抽象类
- 【小笨鸟看JDK1.7集合源码之一】JAVA集合整体框架
- 结对编程
- Spring-Security
- Python Decorator 3: 嵌套
- Python学习笔记(六)——一些语句
- Spring MVC 和 Struts2 的区别?
- Ubuntu下安装了java但启动eclipse报错说没装java
- JAVA使用JDBC连接MySQL数据库
- 夺命雷公狗TP下关联查询