天天看点

git: failed to push some refs to

git: failed to push some refs to
  • 原因:
    • A -- B -- C -- D (on the remote)
      A -- B -- E (on your local machine)
                 
      本地和仓库中的文件不一致,如果push,那么就不能push c和d,在push之前,需要将仓库中的内容下载下来
  • 解决方法:
    • git pull --rebase origin [branch]
      
      git push origin master
                 
      • 这种方法就是先将remote pull下来,然后再push
    • 第二种方法:强制push(不推荐)
      • git push --force origin master
                   
  • 相关连接:
    • 相关链接1
git