首先要保证SSH key在账户列表中,本地仓库和远程仓库已经关联
这个时候如果报错信息是:
$ git push -u origin master
To git@github.com:xxxxxxxxx.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:yangchao0718/cocos2d.git
hint: Updates were rejected because the tip of your current branch is behin
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.
可以尝试使用如下命令:git pull --rebase origin master
造成上述问题的原因是远程仓库中初始化存在README.MD文件,本地却没有,使用上述命令可将远程的README.MD文件拉下来,此时再推代码就可以推上去了