问题1.先创建本地库,后拉取远程仓库时上传失败的问题怎么解决?
操作主要步骤:
step1 设置远程仓库地址:
$ git remote add origin git@gitee.com:yourAccount/reponamexxx.git
step2 推送到远程仓库:
$ git push -u origin "master"
报错信息:
To gitee.com:konallzong/technical-books.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'gitee.com:yourAccount/reponamexxx.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.
解决办法:
step1 拉取远程仓库,使用 --allow-unrelated-histories选项,本质上是合并(merge):
$ git pull origin master --allow-unrelated-histories
step2:在来一把,不带该选项。
$ git pull origin master
step3:推送
$ git push -u origin "master"