github+hexo builds a blog, push local code to github error

  • When uploading from the git client, it keeps reporting an error, showing that it cannot be uploaded to github
  • The error message is as follows
$ git push -u origin master 
To [email protected]:**/Demo.git 
! [rejected] master -> master (non-fast-forward) 
error: failed to push some refs to ‘[email protected]:**/Demo.git’ 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Merge the remote changes (e.g. ‘git pull’) 
hint: before pushing again. 
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
  • Solution (ask Du Niang, because I just built it, so I chose the first one, forced push, if you have already built a blog, choose other methods -> The first one is the easiest and fastest )
    • Reason: The conflict between the remote repository and my local repository is caused. After creating the repository, I clicked the button to create the README.md file on the repository page of github to create the documentation, but it was not pulled locally. This creates a version conflict problem.
    • The methods are as follows:
  1. Use the method of forced push:
$ git push -u origin master -f
  • This will make remote modifications lost, which is generally not desirable, especially when multiple people collaborate on development.
  1. Before push, modify the remote repository and pull it down
$ git pull origin master

$ git push -u origin master
  1. If you don't want to merge remote and local modifications, you can create a new branch first:
$ git branch [name]
  • then push
$ git push -u origin [name]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325077866&siteId=291194637