Push to origin/master was rejected

Problem Description

insert image description here

The codes of the local warehouse and the remote warehouse are different. In simple terms, it means that the code conflicts. In complex terms, it means that you have moved the code that should not be moved.

solution:

  1. The general problem of code conflicts is that you typed a space, tab, or rolled your face on the keyboard in the code, resulting in something that should not have appeared in the code. At this point, all you need to do is to undo with Ctrl + z to restore the code, and be careful not to withdraw the code you modified yourself. After all, the brain is a good thing.

  2. Right-click on the directory location corresponding to the git project to open Git Bash Here (note the location of the project directory)
      
    and enter the following command in the command window:
    git pull origin master --allow-unrelated-histories

    Finally, if the completion message appears, the operation is successful!

    Push the code again and submit successfully! ! !

    The conjecture of this command is: allow irrelevant historical commits. similar to try

  3. The simple and crude method is to directly re-Clone the code, then re-add the code you modified, and then try to push it. Guaranteed to resolve successfully.

Reference: https://blog.csdn.net/mygodit/article/details/84869504

Guess you like

Origin blog.csdn.net/qq_44678607/article/details/130175686