使用git更新远程仓库的时候报branch-is-behind错误

使用git更新远程仓库的时候报Updates were rejected because the tip of your current branch is behind错误

今天使用git更新GitHub仓库的时候出现了错误,具体错误如下

1
2
3
4
5
6
7
To github.com:Anthony-Duan/hbasetrain.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Anthony-Duan/hbasetrain.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.

错误原因其实是我本地没有README.md这个文件,而远程仓库中有,
如何解决那?
很简单
git pull --rebase origin master
执行这一句就行了
执行完后会发现本地已经有了 README.md 这个文件

然后就是常规操作了
git push -u origin master
之后就可以看到GitHub上已经有了刚上传的新鲜代码啦!

-------------End Of This ArticleThank You For Reading-------------