一、 git push时提示和远程分支有冲突
error: failed to push some refs to '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.
解决方法:
1. 远程修改与本地无冲突,顺利合并
- git pull,同步远程分支
- git push,再提交
2. 远程修改与本地有冲突
- 如果有冲突,会提示:error: Your local changes to the following files would be overwritten by merge: Please commit your changes or stash them before you merge.
- git stash,暂存本地修改
- git pull,同步远程分支
- git stash pop,恢复本地修改,这一步会提示哪些文件有冲突,手动处理