There was a problem when creating the project, please see where I went wrong
Writing code locally
Create a new project on github and create readme.md directly using github
git remote add origin git@github.com:xxx/xxx
git push -u origin master
Here, the error starts:
error: failed to push some refs to 'git@github.com:xxx'
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.
Then, git pull
, another error was reported:
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From github.com:xxx
+ 8324a8d...8c9fdd4 master -> origin/master (forced update)
fatal: refusing to merge unrelated histories
What's wrong with this? What's the correct way to push a git project
The solution to your second error is as follows
The correct way to use git is
Generally speaking, a warehouse can only have one initial submission point. If you create an initial submission through Github and create an initial submission locally, naturally an error will be reported when pushing locally.
If you choose to initialize the warehouse through a readme or the like when creating a project on Github, you should clone the remote warehouse locally instead of creating a new warehouse and binding the remote warehouse.
If you did not select the warehouse initialization option when you created the project on Github, you can create a new warehouse locally, bind it to the remote warehouse, and push the local initial submission to the remote warehouse.