問題 :gitte遠程倉庫修改后,本地沒有更新,本地與遠程倉庫不一致
現象:
[cxq@iZwz9fjj2ssnshikw14avaZ rpc]$ git push
Username for 'https://gitee.com': beihangya
Password for 'https://beihangya@gitee.com':
To https://gitee.com/beihangya/rpc.git! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/beihangya/rpc.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 merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解決方案
1、拉取遠程更改:
首先從遠程倉庫拉取最新的更改并合并到本地:
git pull origin master
如果有沖突,需要手動解決沖突。
2、解決沖突:
如果拉取過程中出現沖突,根據提示解決沖突
3、再次推送:
解決沖突并合并遠程更改后,再次嘗試推送:
git pull origin master