前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >github+hexo搭建博客,push本地代码到github出错

github+hexo搭建博客,push本地代码到github出错

作者头像
运维小白
发布2018-04-16 17:14:03
1.4K0
发布2018-04-16 17:14:03
举报
文章被收录于专栏:运维小白运维小白
  • 在git客户端上传的时候一直报错,显示无法上传到github
  • 报错信息如下
代码语言:javascript
复制
$ git push -u origin master 
To git@github.com:**/Demo.git 
! [rejected] master -> master (non-fast-forward) 
error: failed to push some refs to ‘git@github.com:**/Demo.git’ 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Merge the remote changes (e.g. ‘git pull’) 
hint: before pushing again. 
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
  • 解决方法(问度娘的,因为自己是刚搭建的,所以选择了第一种,强制push,若是你已经搭建好的博客,还是选择其他几种方法——>第一种最省事,最快)
    • 原因:远程repository和我本地的repository冲突导致的,而在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。
    • 方法如下几种:
  1. 使用强制push的方法:
代码语言:javascript
复制
$ git push -u origin master -f
  • 这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。
  1. push前先将远程repository修改pull下来
代码语言:javascript
复制
$ git pull origin master

$ git push -u origin master
  1. 若不想merge远程和本地修改,可以先创建新的分支:
代码语言:javascript
复制
$ git branch [name]
  • 然后push
代码语言:javascript
复制
$ git push -u origin [name]
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档