A project is created locally and a warehouse is created on GitHub. To link the local warehouse to the remote warehouse, I use the following method:
git init initialize the local warehouse
git remote add origin XXX add the remote warehouse address
if you execute
git add – a after that,
Git commit – M ”
git push origin master, then this problem will appear (rejected), so after remote add, don’t worry about git add, be sure to git pull origin master, the reason for this is that you have readme files in the warehouse created by code cloud, but not locally, which causes local and remote out of sync,
Then there are two solutions:
Method 1:
if there is no local readme file, a local readme file will be generated
Git pull — rebase origin master local generation of readme files
git push origin master
Method 2:
then I will force the upload to cover the remote file,
git push – f origin master
Similar Posts:
- How to Solve error: failed to push some refs to ‘xxxx’
- [Solved] error: failed to push some refs to ‘xxxx’
- Git Push hint: Updates were rejected because the remote contains work that you do hint: not have …
- [Solved] gitee Push Error: error: failed to push some refs to
- How to Solve Error: failed to push some refs to git
- Updates were rejected because the remote contains work that you do
- Git | fatal: refusing to merge unrelated histories [How to Solve]
- [Solved] Updates were rejected because the tip of your current branch is behind
- Git Pull Error: Please specify which branch you want to merge with.