赞
踩
问题信息:
当我们将本地代码上传至服务器时,git push -u origin master
报如下错误信息
问题原因:在新建的仓库的时候,勾选了README.md, 远程仓库的README.md不在本地仓库中.(同理,如果远程仓库中具有的文件,本地仓库没有,就会有冲突,此时就需要去合并)
- $ git push -u origin master
- To http://xxxxxxxxx/xxxxx/xxxx.git
- ! [rejected] master -> master (fetch first)
- error: failed to push some refs to 'xxxxxxxxx/xxxxx/xxxx.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.
解决方案:
git pull --rebase origin master
- $ git pull --rebase origin master
- warning: no common commits
- remote: Enumerating objects: 3, done.
- remote: Counting objects: 100% (3/3), done.
- remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
- Unpacking objects: 100% (3/3), done.
- From http://xxxxxxxx/xxxxxxx/xxxx.git
- * branch master -> FETCH_HEAD
- * [new branch] master -> origin/master
- First, rewinding head to replay your work on top of it...
- Applying: first commit
然后再重新git push -u origin master
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。