在新建远程仓库,向远程仓库推送时,发生了报错,信息如下
To github.com:Mrzhangxi/teacher.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Mrzhangxi/teacher.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.
在网上找到了解决方案,可以通过加 “-f”来强制提交
G:\teachers>git push -u origin master -f
附:新建远程和本地仓库,进项关联推送
第一步:在本地文件夹执行:git init
第二步:在远端创建项目,绑定ssh key
第三步:在本地执行git remote add origin gitxxxx.git ,后边为github项目上的SSH 链接
第四步:拉取远端master,git pull origin master
第五步:提交git push -u origin master,如果报错的话,加-f,git push -u origin master -f