Common errors
The content of the error report is basically error: failed to push some refsto’remote warehouse address’.
Causes
We want to associate a local project with a remote warehouse and push it
Operation
- Local project—>remote warehouse—>local associated remote—>push the latest code
- Errors are often found in the last step
Root Cause
When we create a warehouse, we always check the “Use Reamdme file to initialize this warehouse” This operation first met a README file and configured to add an ignore file. When clicking to create a warehouse,
It will do an initial commit for us. So our warehouse has README.m and .gitignore files, and then we associate the local project to this warehouse and push the project to the warehouse. When we associate the local and remote, both ends have content, but These two contents are not related. When we push to or pull content from remote, there will be untracked content, so you will always ask you to pull first and then push in the detailed errors reported by git, but Pull always fails.
Solution
Method 1
For error: failed to push some refsto’remote warehouse address’
1 Use the following command
git pull –rebase origin master
2 Then upload again:
git push -u origin master
Push successfully
Method 2
- To avoid this kind of problem, just The repo to keep created is an empty repo with nothing.
- When creating a warehouse, do not check “Use the Readme file to initialize this warehouse”
- Then clone it for easy use, and you can push it directly next time you want to push it.
Original link: https://blog.csdn.net/qq_45893999/article/details/106273214