1、git push -u origin master出现 Updates were rejected because the remote contains work that you do
原因:本地repository和远程repository中文件有被修改发生冲突需要合并
解决:
本以为可以解决了 于是执行git push -u origin master
又出现错误,见下2
2、git push -u origin master
出现Updates were rejected because the tip of your current branch is behind
原因和上面问题的原因应该一样
解决:
继续执行git pull origin master 提示:fatal: refusing to merge unrelated histories
3、执行git pull origin master
出现 fatal: refusing to merge unrelated histories
原因:本地版本库和远程还是两个版本的库,未进行关联
解决:git pull origin master --allow-unrelated-histories
注意一定不要忘了中间的-
4、若执行完显示Automatic merge failed; fix conflicts and then commit the result
说明依然存在冲突,需要手动解决
git status查看状态发现 有未merge的文件
找到文件,查看内容 指令:cat+文件名 显示difference
一般使用<<<<<<<<和==========区分
修改内容
git add file
git commit -m “conflict fixed”
执行git log 查看conflict是否fixed
最后执行关键一步 git push -u origin master