错误: 当我们执行:git push -u origin master
命令向码云或者GitHub上传时,出现如下错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘gitee.com:kenslu/conmmunity.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文件不在本地代码文件夹中。
就是远程仓库比你的本地仓库东西要多。多人协作的时候,一般时先pull下来,然后再上传。
解决办法: 可以通过如下命令进行代码合并【注:pull=fetch+merge]
git pull --rebase origin master
执行之后,会发现本地代码库中多了README.md文件。
此时,在次执行 git push -u origin master
命令,就可以发现上传成功。