The only way
If you are a git novice, through online tutorials that one learned how to use git bash to push their projects to a remote repository. Then you will come across the following issues:
error: failed to push some refs to ‘ur repository’
Pit of 必踩
And if you Baidu this problem, you will get exactly the same answers to the first three pages in Baidu search:
Problem ( non-the FAST Forward- reason) is that:
git repository has been part of the code, so it does not allow you to directly cover up your code. So you have 2 mode options:
1, strong push, i.e. the use of strong cover git repository alternate contents with your local code
$git push -f
2, the first thing git fetch then merge and then to your local Push
$git fetch
$git merge
Above are all shit
If you really did that:
- The first method will be completely overwritten before you commit. If you submit just a few modifications, it is really worth the candle.
- The second method did not use any eggs.
The Ultimate Solution
The root cause (non-fast-forward) is the repository already exists and is not a project that you submit myself (I know that is a high probability that you submitted, but only recognize git address), you commit projects and remote repo is not the same. Then how to do it? Very simple, the distal end of the project back to the local:
$ git pull
However, after the pull back, then push you will still fail.
The reason is that they are two different projects, it should merge two different projects, not simply git pull
. But
$ git pull origin master --allow-unrelated-histories
This command allows the merging of different projects.
Well, pull a success.
Next
$ git push origin master
Game over over ~
thank
If you solve a difficult problem, give praise Ha, thank you ~