error: failed to push some refs to git的解决办法
Posted 「已注销」
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了error: failed to push some refs to git的解决办法相关的知识,希望对你有一定的参考价值。
本地创建了版本库,github上面也创建了仓库,但是在本地使用push,pull命令都没有用,提示错误
错误代码:
$ git push -u origin master
To github.com:wangqh7812/Demo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:wangqh7812/Demo.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文件没有拷贝到本地仓库来,导致本地无法push
解决办法:
需先对本地和远程仓库进行整理合并
代码:
$ git pull --rebase origin master
From github.com:wangqh7812/Demo
* branch master -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: 整理
Applying: add test.txt
然后再进行push
代码:
$ git push -u origin master
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 68.06 KiB | 251.00 KiB/s, done.
Total 18 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), done.
To github.com:wangqh7812/Demo.git
59a348c..75a232c master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
完美解决!
以上是关于error: failed to push some refs to git的解决办法的主要内容,如果未能解决你的问题,请参考以下文章
Git上传提示error: failed to push some refs to
error: failed to push some refs to
git 错误error: failed to push some refs to
git常见错误:error: failed to push some refs to 'xxx'
git push error: ! [rejected] failed to push some refs to . . .