Git命令遇到错误:
! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://gite
$ git push origin-1 master
To https://gitee.com/hatingyu/Git_1.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/hatingyu/Git_1.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.
原因:
出现错误的主要原因是gitee中的README.md文件不在本地代码目录中
此时我们要执行git pull --rebase origin-1 master命令将README.md拉到本地,
然后执行git push origin-1 master就可以成功了
(提示: origin-1是远程仓库地址的一个别名,记得改)