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

    copy from :https://blog.csdn.net/k_young1997/article/details/90489734

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

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

    如果报如下错误,也可以用 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.

    1
    2
    3
    4
    5
    6
    用 git pull origin master --allow-unrelated-histories 解决
    ————————————————
    版权声明:本文为CSDN博主「Been_You」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/k_young1997/article/details/90489734

    Always Believe Something Beauitful Will Be Happen
  • 相关阅读:
    CSS的四种基本选择器和四种高级选择器
    Leetcode 897 递增顺序查找树
    Leetcode 872 叶子相似的树
    Leetcode 700 二叉搜索树中的搜索
    Leetcode 二叉树中第二小的节点
    Leetcode 669 修剪二叉搜索树
    Leetcode 653 两数之和IV
    Leetcode 637二叉树的层平均值
    Leetcode 617 合并二叉树
    Leetcode 606 根据二叉树创建字符串
  • 原文地址:https://www.cnblogs.com/Oude/p/12304460.html
Copyright © 2011-2022 走看看