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

前端 未结 17 1199
梦如初夏
梦如初夏 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 04:59

    I had the same problem. It happened that I have created .Readme file on the repository without pulling it first.

    You may want to delete .Readme file or pull it before pushing.

    0 讨论(0)
  • 2020-11-22 05:06

    The best option for me and it works and simple

    git pull --rebase

    then

    git push

    best of luck

    0 讨论(0)
  • 2020-11-22 05:10

    you can use

    git pull --rebase <your_reponame> <your_branch>
    

    this will help incase you have some changes not yet registered on your local repo. especially README.md

    0 讨论(0)
  • 2020-11-22 05:11

    This usually happens when the repo contains some items that are not there locally. So in order to push our changes, in this case we need to integrate the remote changes and then push.

    So create a pull from remote

    git pull origin master
    

    Then push changes to that remote

    git push origin master
    
    0 讨论(0)
  • 2020-11-22 05:11

    Well actually github is much simpler than we think and absolutely it happens whenever we try to push even after we explicitly inserted some files in our git repository so, in order to fix the issue simply try..

    : git pull

    and then..

    : git push

    Note: if you accidently stuck in vim editor after pulling your repository than don't worry just close vim editor and try push :)

    0 讨论(0)
  • 2020-11-22 05:13

    You need to input:

    $ git pull
    $ git fetch 
    $ git merge
    

    If you use a git push origin master --force, you will have a big problem.

    0 讨论(0)
提交回复
热议问题