zoukankan      html  css  js  c++  java
  • 解决error: failed to push some refs to 'xxxx'

    今天将项目修改了一部分,然后用 git push origin master 向远程仓库推送的时候报如下错误:

    error: failed to push some refs to 'https://github.com/ZJyoung1997/JZShop.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.

    原因是远程仓库中的文件和我们本地的仓库有差异,例如你的远程仓库有个文件Readme. md,但是本地仓库却没有,就可能会出现这种情况。 我的就是远程仓库中有Readme. md文件,而本地仓库中没有该文件造成的。还有就是因为平时在协会中,用协会电脑开发,回到寝室后又会用自己的电脑开发,这可能也是导致这种问题的原因。这种情况有解决办法,就是将本地仓库直接干掉,然后重新从远程clone一个,但是这样显然太麻烦了,可以用合并分支的方法

    解决办法:

    git pull --rebase origin master

    git pull命令用于从另一个存储库或本地分支获取并集成(整合),取回远程主机某个分支的更新,再与本地的指定分支合并。

    fatal: 'master' does not appear to be a git repository
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.

    用 git pull origin master --allow-unrelated-histories 解决

    原文地址:解决error: failed to push some refs to 'xxxx'

  • 相关阅读:
    字符串与数字相互转换
    CodeForces
    解救迷茫的草滩小王子
    Ubuntu18.0.4 apt换源
    N进制与十进制之间的 转换(整数,小数)
    2019-10-10问题
    千里之行始于足下,付出总会有回报
    git--基本命令篇
    C#-网络请求方法
    爬虫实战-网易云音乐
  • 原文地址:https://www.cnblogs.com/webqiand/p/15511965.html
Copyright © 2011-2022 走看看