[Solved] The first push of the git project prompts error: failed to push some refs to ‘https://github.com/xxx

Problem description: When your project is not pulled from the remote warehouse first, and then pushed, there may be a push rejected problem,

![rejected] cfj -> cfj (non-fast-forward)
error: failed to push some refs to ‘https://gitee.com/xxx
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes

It can be solved by the following methods: if it helps, follow and like~~~~~

After solving the problem through the command line,Idea is used to operate the push, and the pull is all normal.

1. First find the local warehouse location of the project

2. Right click to open git base here

3. First make sure that the remote warehouse connection is correct and there is no abnormality

Use the git command to check whether the project is properly connected to the remote repository. The following figure shows that the connection is normal!

git remote -v

If the connection is incorrect, please configure the correct remote repository first; If the connection is normal, there are two ways to solve it:

* * The first way: upload by forced push

git push -f origin master

Local code successfully uploaded! ! ! Then use Idea to operate push, and everything is normal for pull.

** The second way: first perform the pull operation from the remote warehouse, and then perform the push upload

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

In the figure, since I have successfully uploaded using method 1, there is no change operation in the warehouse here. Then use Idea to operate push, and everything is normal for pull.

At the end of the flower, I hope to give a like~~~~~