push到github报错解决方法
Posted Jo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了push到github报错解决方法相关的知识,希望对你有一定的参考价值。
在push代码到远程仓库时,报了如下的错误:
$ git push -u origin master
To https://github.com/11pdg/group-buy.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/11pdg/group-buy.git‘
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull ...‘) before pushing again.
hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.
查阅资料得知,是因为在github上创建仓库的时候,顺便也创建了README文件,然而本地仓库又没有这个文件,所以导致版本冲突。
有以下几种解决方法:
1、强制push到远程仓库:
git push -u origin master -f
但是这样会导致远程仓库里的东西丢失,一般不会采用这样的方法,特别是团队开发的时候。
2、push前先将远程仓库pull下来,再进行push:
git pull origin master
git push -u origin msater
3、创建新的分支:
git branch [name]
git push -u origin [name]
以上是关于push到github报错解决方法的主要内容,如果未能解决你的问题,请参考以下文章
解决git push报错:failed to push some refs to ‘git@github.com:anightmonarch/JavaEasyGoing.git‘
解决git push报错:failed to push some refs to ‘git@github.com:anightmonarch/JavaEasyGoing.git‘
解决git push报错:failed to push some refs to ‘git@github.com:anightmonarch/JavaEasyGoing.git‘
错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read | 使用命令行提交代码 )(代码
错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read | 使用命令行提交代码 )(代码
git执行push命令到远程仓库报错OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443