I come up with a problem about Git push.
It worked successfully before, but it failed this time. In the beginning, I am in my master MINGW64 /d/javasoft/apache-tomcat-7.0.70/webapps/MyNote (master)
, and then,
- I use
git remote add origin
to relate my remote origin, but it alerts thatfatal: remote origin already exists.
- then, I use
git remote rm origin
(Someone told me to), and it's OK. - then, I use
git remote add origin https://github.com/***/***.git
again. It's OK. - then, I use
git push -u origin master
( I triedgit push origin master
, but I lost my local whole.git
for some reason before, so I guess it may be the first time to push, and I should add-u
). BUT, it alertserror: failed to push some refs to 'https://github.com/***/***.git'
- then, someone told me that I should use
git pull origin master
before I usepush
, and I did as it. but, it alerted:fatal: refusing to merge unrelated histories
. - I found some answers in Git refusing to merge unrelated histories on rebase, but it seemed that it didn't work. In my issue, it alerted
fatal: Couldn't find remote ref –allow-unrelated-histories
How can I do it? I just want to push...
–allow-unrelated-histories
flag in your case. Instead you should restore the history of your code, so that the last commit from the origin history you have in your code is its parent, then merge should give correct result