执行git push 时报错内容
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/…’
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.
解决方法:
对GitHub已存在的仓库进行更新时
- 先把GitHub上要操作的仓库取到本地
git clone 加URL - 新建文件
vi 文件名 - 将新建文件从工作区添加到缓存区
git add 上传文件名 - 将新建文件从缓存区提交到本地仓库
git commit -m “描述” - 将本地仓库文件同步到远程仓库
git push