Git 问题整合

1. 解决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文件,而本地仓库中没有该文件造成的。

git pull --rebase origin master

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

原文地址:https://www.cnblogs.com/Xieyiincuit/p/14839107.html