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

后端 未结 22 1902
萌比男神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 16:55

    I had this problem on a development machine. The dev branch was pushing fine but the the master branch gave me (while git pushing when being on the dev branch):

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

    So I tried:

    git checkout master
    git pull
    

    Which gave me:

    You asked me to pull without telling me which branch you
    want to merge with, and 'branch.master.merge' in
    your configuration file does not tell me, either.
    

    I found out the master branch was missing from .git/config and added:

    [branch "master"]
        remote = origin
        merge = refs/heads/master
    

    Afterwards git push also worked fine on the dev branch.

提交回复
热议问题