https://www.cnblogs.com/code-changeworld/p/4779145.html

刚创建的github版本库,在push代码时出错:

$ 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.

网上搜索了下,是因为远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。

有如下几种解决方法:

1.使用强制push的方法:

$ git push -u origin master -f 

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

$ git pull origin master
$ git push -u origin master

3.若不想merge远程和本地修改,可以先创建新的分支:

$ git branch [name]
然后push
$ git push -u origin [name]

最新文章

  1. node.js操作mysql数据库之增删改查
  2. Ubuntu Filezilla FTP Client 安装
  3. C/C++学习笔记---高地址、低地址、大段字节序、小段字节序
  4. Jquery dialog属性
  5. asp.net用url重写URLReWriter实现任意二级域名
  6. xcode下编译.a文件的路径
  7. 【MySQL】使用mysqlbinlog回滚
  8. Linux系统文件访问控制列表
  9. WebBrowser自动点击链接 广告自动点击 Ads Auto Click
  10. SWIFT学习笔记01
  11. Java _分页Jdbc 版
  12. location.href 本窗口与window.open 新窗口打开用法
  13. 【oracle入门】数据库系统范式
  14. CSS面试题
  15. python迭代-可迭代对象与迭代器对象
  16. 11g统计信息自动收集任务
  17. 【题解】Luogu P2157 [SDOI2009]学校食堂
  18. VM虚拟机的配置文件(.vmx)损坏
  19. Session,Token相关区别
  20. SqlException with message "Caught java.io.CharConversionException." and ERRORCODE=-4220

热门文章

  1. springboot之Redis
  2. X64驱动:内核操作进线程/模块
  3. THUPC2019/CTS2019/APIO2019/PKUSC2019游记
  4. "多层感知器"--MLP神经网络算法
  5. Psychedelic therapy
  6. Go 操作 Mysql(二)
  7. 目标进程已退出,但未引发 CoreCLR 启动事件
  8. angular中控制器之间传递参数的方式
  9. 关于Ad-hoc
  10. spark 机器学习 knn原理(一)