git push 失败与解决方法

在使用 Git 远程提交推送的时候出现了一个报错

git push -u origin master

报错如下:

error: failed to push some refs to 'git@github.com:xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

从提示可以看出,是由于两者不同步,因此需要先 pull,进行合并然后在进行 push,因此先使用

git pull --rebase origin master

将远程文件同步下来,然后再执行推送

git push -u origin master

 

相关文章

Git安装和使用 Git安装和使用 刚开始用git的小白适用,,转自...
fatal: remote origin already exists.解决方法 第一个问题g...
git常用命令(二)查看历史记录 git log [--pretty=oneline]...
git之如何把本地文件上传到远程仓库的指定位置 git专栏收录该...
代码规范之 lint-staged 在代码提交之前,进行代码规则检查能...
方法:1、文件没有git操作时用“git checkout--文件”命令还...