git项目初次push提示 error: failed to push some refs to ‘https://github.com/xxx

编程入门 行业动态 更新时间:2024-10-27 23:30:24

git项目初次push<a href=https://www.elefans.com/category/jswz/34/1771018.html style=提示 error: failed to push some refs to ‘https://github.com/xxx"/>

git项目初次push提示 error: failed to push some refs to ‘https://github.com/xxx

问题描述:当你的项目不是先从远程仓库pull下来,再push的话,可能会出现 push被拒绝问题

 ! [rejected]        cfj -> cfj (non-fast-forward)
error: failed to push some refs to '
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes

可以通过以下方法解决:有帮助的话,关注点个赞~~~~~

通过命令行方式解决问题后,再用Idea 操作push,pull 一切正常。

1.首先找到项目的本地仓库位置

 2. 右键打开 git base here

 3. 首先确定远程仓库连接正确无异常

使用git命令,查看项目是否与远程仓库连接正常 ,下图显示连接正常

git remote -v

 如果连接不正确,请先配置正确远程仓库;如果连接正常的话,可通过以下两种方式进行解决:

* *   第一种方式:通过强制推送的方式进行上传 

git push -f origin master

本地代码成功上传!!! 接着再用Idea 操作push,pull 一切正常。

**   第二种方式:先执行从远程仓库拉取操作,后执行push上传

git pull origin master --allow-unrelated-histories
git push origin master

 图中由于我用方法一已经成功上传,所以这里仓库没有更改操作。接着再用Idea 操作push,pull 一切正常。

完结撒花,有帮助希望点个赞~~~~~

更多推荐

git项目初次push提示 error: failed to push some refs to ‘https://github.com/xxx

本文发布于:2024-02-27 07:42:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1705747.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:提示   项目   error   git   push

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!