300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > git项目初次push提示error: failed to push some refs to https://gitee.com/xxxx/xxx.git’解决方案

git项目初次push提示error: failed to push some refs to https://gitee.com/xxxx/xxx.git’解决方案

时间:2019-06-23 11:35:35

相关推荐

git项目初次push提示error: failed to push some refs to https://gitee.com/xxxx/xxx.git’解决方案

在本地与远程新建仓库并关联后,初次push可能会遇到以下问题

$ git push -u origin masterTo /xxxx/xxx.git! [rejected] master -> master (fetch first)error: failed to push some refs to '/xxxx/gittest.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因是因为远程仓库有一些文件而本地没有,通常是在远程建立仓库时有一些初始化文件比如Readme License 等,并且直接pull会提示warning: no common commits,对于此类问题可以采用两种解决办法

1.git push -f 强制将本地文件推送至远程,这样会将远程仓库的已有的文件清掉

2. git pull origin master –allow-unrelated-histories 使用此命令告诉 git 允许不相关历史合并 这样就能把远程文件拉取回来。执行此命令后会有一个提示,要求说明为何要讲两个不相关的分支合并,输入信息后保存即可。

拉取完不同的文件之后再执行git push -u origin master命令即可push成功。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。