! [rejected] master -> master (fetch first)

后端 未结 24 2861
说谎
说谎 2020-12-02 04:15

Is there a good way to explain how to resolve \"! [rejected] master -> master (fetch first)\'\" in Git?

When I use this command $ git push or

相关标签:
24条回答
  • 2020-12-02 04:39

    You just have to mention your branch name along with your remote name.

    git fetch origin
    git merge origin/master
    
    0 讨论(0)
  • 2020-12-02 04:39

    This worked for me:

    $ git add .
    $ git commit -m "commit"
    $ git push origin master --force
    
    0 讨论(0)
  • 2020-12-02 04:40

    Follow the steps given below as I also had the same problem:

    $ git pull origin master --allow-unrelated-histories 
    

    (To see if local branch can be easily merged with remote one)

    $ git push -u origin master 
    

    (Now push entire content of local git repository to your online repository)

    0 讨论(0)
  • 2020-12-02 04:43

    Your error might be because of the merge branch.
    Just follow this:

    step 1 : git pull origin master (in case if you get any message then ignore it)
    step 2 : git add .
    step 3 : git commit -m 'your commit message'
    step 4 : git push origin master

    0 讨论(0)
  • 2020-12-02 04:44

    As it is stated in the Error message you have to "fetch first." This worked for me. Use the command:

    1. git fetch origin master

    Then follow these steps to merge:

    1. git pull origin master
    2. git add .
    3. git commit -m 'your commit message'
    4. git push origin master
    0 讨论(0)
  • 2020-12-02 04:44

    Sometimes it happens when you duplicate files typically README sort of.

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