1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > git push -u origin master 本地代码上传gitlab远程仓库出错

git push -u origin master 本地代码上传gitlab远程仓库出错

时间:2024-02-09 22:31:10

相关推荐

git push -u origin master 本地代码上传gitlab远程仓库出错

问题信息:

当我们将本地代码上传至服务器时,git push -u origin master

报如下错误信息

问题原因:在新建的仓库的时候,勾选了README.md, 远程仓库的README.md不在本地仓库中.(同理,如果远程仓库中具有的文件,本地仓库没有,就会有冲突,此时就需要去合并)

$ git push -u origin masterTo 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 dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (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 masterwarning: no common commitsremote: Enumerating objects: 3, done.remote: Counting objects: 100% (3/3), done.remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0Unpacking objects: 100% (3/3), done.From http://xxxxxxxx/xxxxxxx/xxxx.git* branch master-> FETCH_HEAD* [new branch]master-> origin/masterFirst, rewinding head to replay your work on top of it...Applying: first commit

然后再重新git push -u origin master

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。