rejected master -> master (non-fast-forward)

后端 未结 22 1905
萌比男神i
萌比男神i 2020-11-30 16:13

I\'m trying to push my project (all files in a new repository). I follow the steps but when I push with git push -u origin master I get this error:



        
相关标签:
22条回答
  • 2020-11-30 17:05

    This is because you have made conflicting changes to its master. And your repository server is not able to tell you that with these words, so it gives this error because it is not a matter of him deal with these conflicts for you, so he asks you to do it by itself. As ?

    1- git pull This will merge your code from your repository to your code of your site master. So conflicts are shown.

    2- treat these manualemente conflicts.

    3-

    git push origin master
    

    And presto, your problem has been resolved.

    0 讨论(0)
  • 2020-11-30 17:06

    NOTICE: This is never a recommended use of git. This will overwrite changes on the remote. Only do this if you know 100% that your local changes should be pushed to the remote master.

    Try this: git push -f origin master

    0 讨论(0)
  • 2020-11-30 17:06

    ! [rejected] master -> master (non-fast-forward)

    Don’t panic, this is extremely easy to fix. All you have to do is issue a pull and your branch will be fast-forward:

    $ git pull myrepo master

    Then retry your push and everything should be fine:

    $ git push github master

    0 讨论(0)
  • 2020-11-30 17:07

    This happened to me when I was on develop branch and my master branch is not with latest update.

    So when I tried to git push from develop branch I had that error.

    I fixed it by switching to master branch, git pull, then go back to develop branch and git push.

    $ git fetch && git checkout master
    $ git pull
    $ git fetch && git checkout develop
    $ git push
    
    0 讨论(0)
提交回复
热议问题