Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

directory

  • The problem
  • To solve
  • At the end

The problem

Git push > create git push > create git push > create git push > create git push

! [rejected] master – > master (the fetch first) error: failed to push some refs to > ‘git.liuzhen007.com/rcelectron…. ‘ hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., ‘git pull … ‘) before pushing again. hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

Error screenshot:

To solve

Try a

The following error message is displayed:

fatal: refusing to merge unrelated histories

Suddenly the circle…

try

Git push:

fatal: The current branch master has no upstream branch.

Error screenshot:

Try to three

Run the following command according to the error message in the preceding figure:

git push –set-upstream origin master

Same error as in the beginning… Is this back to square one?

Try to four

Use the following command to synchronize the code:

git pull origin master –allow-unrelated-histories

Then run the following command to upload the local project code:

git push –set-upstream origin master

Success at last, ha ha 😄

Successful screenshot:

At the end

This operation was a routine operation before, but I didn’t expect it to go wrong this time. I feel that the problem should be in the way of project creation. I checked the automatic add readme. md file when creating the project in git background, which may cause a series of subsequent problems.