如何解决failed to push some refs to git

git push -u origin mastergit

报错 To https://gitee.com/sunki/youshang_web.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/*****'
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.github

此时尝试下面的命令把当前分支代码上传到master分支上。web

$ git push -u origin master
但依然没能解决问题fetch

出现错误的主要缘由是github中的README.md文件不在本地代码目录中;blog

能够经过以下命令进行代码合并【注:pull=fetch+merge]rem

git pull --rebase origin masterit

执行上面代码后能够看到本地代码库中多了README.md文件ast

 

此时再执行语句 git push -u origin master便可完成代码上传到gitsed

相关文章
相关标签/搜索