最新消息:关注【已取消】微信公众号,可以获取全套资料,【全套Java基础27天】【JavaEE就业视频4个月】【Android就业视频4个月】

github提交"error: failed to push some refs to xxx"错误解决

杂文 太平洋学习网 0浏览 评论

github提交项目的时候提示"error: failed to push some refs to xxx"错误,该如何解决呢?后面会讲到,先看看错误代码部分:

D:\web\weixin\jdbcTemplate-example>git push -u origin master

fatal: HttpRequestException encountered.

   发送请求时出错。

Username for 'https://github.com': wjycgl

Password for 'https://wjycgl@github.com':

To https://github.com/wjycgl/jdbcTemplate-example.git

 ! [rejected]        master -> master (fetch first)

error: failed to push some refs to 'https://github.com/wjycgl/jdbcTemplate

le.git'

hint: Updates were rejected because the remote contains work that you do

hint: not have locally. This is usually caused by another repository pushi

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 push -u origin master”命令提交本地代码到远程repository数据库中的时候,就出现了上面的错误。

错误分析:

这是由于本地项目在提交的时候,本地项目与github远程仓库中的项目版本不一致造成的!也就是项目有冲突!

解决方案:

方案一:先使用“git pull”命令将远程的所有项目代码拉取到本地,然后“git push -u origin master”命令提交。

方案二:使用“git push -u origin master -f”强制提交本地项目代码到远程仓库。

说明:

方案二这种方式有个缺点就是,如果对方修改的文件和你提交的此文件是同一个文件,那么就会将对方的代码覆盖掉,如果没有和对方商量的话,对方可能会打死你!

来源网站:太平洋学习网,转载请注明出处:http://www.tpyyes.com/a/zawen/791.html
"文章很值,打赏犒劳作者一下"
微信号: Javaweb_engineer

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

与本文相关的文章

发表我的评论
取消评论

表情

您的回复是我们的动力!

  • 昵称 (必填)

网友最新评论