1.本地项目关联到远程仓库后
$ git push -u origin master
出现下面错误
$ git push -u origin master
To github.com:wa122as/superking.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:wa122as/superking.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原因是没用同步远程代码。
所有我们需要先需要同步一下代码
git pull origin master
然后在提交
或者
$ git push -f origin master 强制推送
$ git push -f origin master
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (18/18), 1.71 KiB | 0 bytes/s, done.
Total 18 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To github.com:wa122as/superking.git
+ 7d59065...6c65c8b master -> master (forced update)