git 提交项目代码到码云步骤 以及出现错误解决办法

时间:2023-03-09 15:31:23
git 提交项目代码到码云步骤 以及出现错误解决办法

git init
git remote add origin 项目地址
git add .
git commit -m "注释"
git push origin master

出现错误 
$ git push origin master
To https://gitee.com/heguxin/XXX
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/heguxin/XXX
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 --rebase origin master
git push origin master