git合并代码之.gitignore

2016-04-18  本文已影响780人  可齐

在git合并代码的过程中,反复遇到一个问题:不同机器上传的代码,在git pull时候报错如下

error: Your local changes to the following files would be overwritten by merge:
.DS_Store

Please, commit your changes or stash them before you can merge.

原因

解决办法

成功在即

好了,现在删除下你本地的.DS_Store,然后再pull一次吧,大功告成~

2016-4-21更新

哎,又出新的坑了,手动删除.DS_Store,还是不管用!。。。google结果如下,执行后,再pull就没事了

http://stackoverflow.com/questions/14744993/git-strange-branch-merge-error-that-i-am-not-sure-how-to-solve

rm .DS_Store
git add -A
git commit -m "Added .gitignore file"

感谢stackoverflow 感谢warrenm

如果你的.DS_Store未忽略就已经push上传,那么它已经被git跟踪,需要执行终端清理git缓存,

    git rm -r --cached [文件名]

    git rm -r --cached .DS_Store

重置所有跟踪

    git rm -r --cached .
    git add .
    git commit -m 'update .gitignore'

生成ignore文件工具

发现一个工具,可以生成各种语言环境下ignore文件
https://www.gitignore.io/

上一篇 下一篇

猜你喜欢

热点阅读