解决 error: failed to push some refs to 'https://github.com/

简介: Resolve error: failed to push some refs to \'https://github.com/

Resolve error: failed to push some refs to \'https://github.com/

报错:

! [rejected] main -> main (fetch first)
error: failed to push some refs to ' https://github.com/XXX.git'

原因:远程库和本地库不一致。通常出现在初始化仓库有readme而本地没有等情况。

提示:git的提示同上。

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方法:

git pull --rebase origin master

原理:

把远程库中的更新合并到本地库中,–-rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。然后再进行push即可。

git pull -–rebase origin master 操作,意为先取消commit记录,并且把它们临时保存为补丁(patch)(这些补丁在”.git/rebase”目录中),之后同步远程库到本地,最后合并补丁到本地库之中。

注意:距离上次push提交至今,在本地库commit的记录均暂存为patch。

目录
相关文章
|
2月前
|
缓存 网络协议 Linux
百度搜索:蓝易云【解决github push/pull报错443】
通过以上方法,你有望解决GitHub push/pull报错443的问题。如果问题仍然存在,建议检查GitHub的状态页面,看是否有正在维护或故障的情况。
81 3
|
3月前
|
开发工具 git
github clone Failed to connect to github.com port 443 after xxx ms
github clone Failed to connect to github.com port 443 after xxx ms
77 2
|
1天前
|
缓存 IDE Linux
Internal error. Please report to https://jb.gg/ide/critical-startup-errors
Internal error. Please report to https://jb.gg/ide/critical-startup-errors
5 0
|
21天前
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
21 5
|
2月前
|
Linux 开发工具 git
【开发专题_03】unable to access ‘https://github.com/deviantony/docker-elk.git/‘: Failed connect to github
【开发专题_03】unable to access ‘https://github.com/deviantony/docker-elk.git/‘: Failed connect to github
|
2月前
|
Kubernetes 容器
使用kubeadm部署k8s报错:The kubelet is not running或者level=error msg="Handler for POST /v1.43/images/create returned error: Head \"https://us-west2-dock
使用kubeadm部署k8s报错:The kubelet is not running或者level=error msg="Handler for POST /v1.43/images/create returned error: Head \"https://us-west2-dock
|
4月前
|
Windows
Windows【工具 01】视频下载工具BBDown.exe详细使用说明(https://github.com/nilaoda/BBDown)mp4格式无法识别问题处理(最新版本1.6.1网盘分享)
Windows【工具 01】视频下载工具BBDown.exe详细使用说明(https://github.com/nilaoda/BBDown)mp4格式无法识别问题处理(最新版本1.6.1网盘分享)
204 0
|
4月前
|
Shell 开发工具 数据安全/隐私保护
git上传项目一直报一个文件没有添加任何内容(git上拉去别人的项目上传到自己的仓库/error: failed to push some refs to ‘https://gitee.com/)
git上传项目一直报一个文件没有添加任何内容(git上拉去别人的项目上传到自己的仓库/error: failed to push some refs to ‘https://gitee.com/)
61 0
git上传项目一直报一个文件没有添加任何内容(git上拉去别人的项目上传到自己的仓库/error: failed to push some refs to ‘https://gitee.com/)
|
4月前
【Error】fatal: unable to access ‘https://github.com/PanJiaChen/vue-element-admin/‘: OpenSSL SSL_read:
【Error】fatal: unable to access ‘https://github.com/PanJiaChen/vue-element-admin/‘: OpenSSL SSL_read:
|
1月前
|
前端开发
webpack如何设置devServer启动项目为https协议
webpack如何设置devServer启动项目为https协议
136 0