push本地代码到github出错
2023-09-27 14:20:50 时间
$ 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]
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]
相关文章
- GitHub 又一开源神器!写代码、搜问题,全部都在「终端」完成!
- github
- iOS-国家代码选择功能github开源分享
- GitHub Creating a personal access token
- 将github代码发布到CocoaPods
- github代码分支
- 使用码云加速下载github项目
- git 使用流程(使用代码库github)
- GitHub Actions CI/CD Pipeline with Docker
- 如何用git将项目代码上传到github
- github copilot 代码智能提示 AI代码提示
- nodejs 简单的备份github代码初版
- 记一次完整地简单地使用Jenkins,Docker,Docker-Compose,Github自动化部署Nodejs代码的过程;Jenkins快速入手
- IDEA项目上传到github
- Android基础-系统架构分析,环境搭建,下载Android Studio,AndroidDevTools,Git使用教程,Github入门,界面设计介绍
- 走你!Github 开源整合
- 一篇文章了解Github和Git教程
- 往github提交代码流程
- 收藏github站点
- GitHub Actions 工作流
- react-native-swiper的Github地址
- 教你上传代码到码云(与github一样)
- win10+hexo+github搭建个人博客
- 工程(十)——github代码ubuntu20.04在ROS环境运行单目和RGBD相机ORB-SLAM3稠密
- ubuntu终端代码上传github最简方法
- idel上传代码到github时遇到的Push rejected: Push to origin/master was rejected
- 首次使用git上传本地项目到github上
- 解决git clone太慢,亲测有效,只需要将www.github.com改为www.github.com.cnpmjs.org
- GitHub托管BootStrap资源汇总
- Git学习:如何在Github的README.MD文件下添加图片
- 谷歌BigQuery现在允许查询所有GitHub开源项目了
- 本地仓库初始化并关联到GitHub仓库,进行代码的上传,以及相关错误 fatal: refusing to merge unrelated histories 解决方案