Today, I modified part of the project, and then used git push origin master
to push it to the remote warehouse. The following error was reported:
error: failed to push some refs to 'https://github.com/ZJyoung1997/JZShop.git'
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.
The reason is that the files in the remote warehouse are different from our local warehouse. For example, your remote warehouse has a file readme. MD, but the local warehouse does not. This may happen. My problem is that there is a readme. MD file in the remote warehouse, but there is no such file in the local warehouse. Another reason is that usually in the association, we use the association’s computer to develop, and when we go back to the dormitory, we will use our own computer to develop. This may also be the reason for this problem. There is a solution to this situation, which is to kill the local warehouse directly, and then clone one from the remote, but this is obviously too cumbersome, you can use the method of merging branches
terms of settlement:
git pull --rebase origin master
Git pull command is used to obtain and integrate (consolidate) from another repository or local branch, retrieve the update of a branch of the remote host, and then merge with the local specified branch.
If the following error is reported, you can also use the git pull
command
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
use git pull origin master --allow-unrelated-histories
to fix
Similar Posts:
- [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
- Git | fatal: refusing to merge unrelated histories [How to Solve]
- How to Solve Error: failed to push some refs to git
- Git Push Error: rejected error: failed to push some refs to… [How to Solve]
- error: src refspec master does not match any [How to Solve]
- [Solved] Git pull fatal: refusing to merge unrelated histories