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

后端 未结 24 2859
说谎
说谎 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条回答
  • Please try this command to solve it -

    git push origin master --force
    

    Or

     git push origin master -f
    
    0 讨论(0)
  • 2020-12-02 04:33

    You can use the following command: First clone a fresh copy of your repo, using the --mirror flag:

    $ git clone --mirror git://example.com/some-big-repo.git
    

    Then follow the codes accordingly:

    Adding an existing project to GitHub using the command line

    Even if that doesn't work, you can simply code:

    $ git push origin master --force 
    

    or

    $ git push origin master -f
    
    0 讨论(0)
  • 2020-12-02 04:35

    this work for me

    1. git init

    2. git add --all

    3.git commit -m "name"

    4.git push origin master --force

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

    ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:'

    Successfully solved the problem using --force command. so, you must used
    git push origin master --force

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

    pull is always the right approach but one exception could be when you are trying to convert a none-Git file system to a Github repository. There you would have to force the first commit in.

    git init
    git add README.md
    git add .
    git commit -m "first commit"
    git remote add origin https://github.com/userName/repoName.git
    git push --force origin master
    
    0 讨论(0)
  • 2020-12-02 04:39

    Try this git command

    git push origin master --force
    

    or short of force -f

    git push origin master -f

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