赞
踩
使用GitHub push的时候报错
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/nat-weiting/snailshop.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原因:
远程库的资源已经由你同一个团队的其他人员(有权限push到这个远程库的人)对资源进行了修改,也就是说,你本地库的资源已经落后于远程库,不是最新的了,这这样的情况下对未更新的地方做修改,GitHub是不允许此时再push的,等于你们产生了冲突
解决方法:
先把远程库的拉取到你本地仓库来,在最新的版本下进行修改以后,再次上传即可。
1.拉取(当然你也可以先fetch再merge):
git pull [远程库url] [分支名]
git pull origin master
查看你更新的文件内容 cat 文件夹名
发现如下为冲突表现
2.手动编辑冲突的地方,删除git给你在文件中警告的提示符号,至于内容得由你们去商量怎么改了
3.修改好后再次将修改的内容add、commit、 push
git add b.txt
git commit -m "resolve conflit" //注意解决冲突再次提交不要在后面加文件名
git push origin master
成功
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 553 bytes | 110.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/nat-weiting/snailshop.git
d0ae636..e7d0c58 master -> master
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。