When idea uses git to submit the project, Push rejected: Push to origin/master was rejected

Today, when I pushed to a new github repository (there is only one README.md file), I have been unsuccessful, and reported an error rejected: Push to origin/master was rejected . Baidu said for a long time that it was because git refused to merge two unrelated things. , And finally found a solution. as follows

F:\javaProject\xl-blog>git pull origin master --allow-unrelated-histories
From https://github.com/lifestravel/java-blog
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

F:\javaProject\xl-blog>git status
On branch master
nothing to commit, working tree clean

Open the terminal and enter the command in the root directory of the local warehouse

git pull origin master --allow-unrelated-histories

This means that it is allowed to pull two unrelated histories.
Explain that the following information shows success:

From https://github.com/lifestravel/java-blog
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

Then go to VCS->Git->push in the Idea directory. Push successfully!

View git status

F:\javaProject\xl-blog>git status
On branch master
nothing to commit, working tree clean

All content is pushed.

Guess you like

Origin blog.csdn.net/qq_44134480/article/details/108189662
Recommended