git: updates were rejected because the remote contains work that you do not have locally

前端 未结 17 1433
梦如初夏
梦如初夏 2020-11-22 04:54

I\'m working on a team with a few developers using git on BitBucket. We are all working on a dev branch, not pushing to master until a release.

17条回答
  •  無奈伤痛
    2020-11-22 05:14

    It happens when we are trying to push to remote repository but has created a new file on remote which has not been pulled yet, let say Readme. In that case as the error says

    git rejects the update

    as we have not taken updated remote in our local environment. So Take pull first from remote

    git pull
    

    It will update your local repository and add a new Readme file. Then Push updated changes to remote

    git push origin master
    

提交回复
热议问题