Error:
$ git push form1 master To
https://github.com/prochka/form-captchaNumber-ajax ! [rejected]
master – & gt; master (fetch first) error: failed to push some refs to
‘https://github.com/prochka/form-captchaNumber-ajax ‘hint: Updates were rejected because the remote contains work that you
dohint: not have locally. This is usually caused by another repository
pushinghint: to the same ref. You may want to first integrate the remote
changeshint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for
details.
The GitHub repository has just been created and there are no changes there
Answer 1, authority 100%
You have changes there that are not in the local repository. You did not make an empty repository on Github, but with an initial commit. The local repository has its first commit and these commits, as you understand, are not equal (in fact, you just have two different repositories).
Just delete the .git
folder locally, re-create the repository (git init
), write upstream (git remote add ...
) and after that you can do git pull
. Should help 🙂
Answer 2, authority 86%
Translating https://stackoverflow.com/a/44442333/5574962
I had the same error when I first created a local repository. Then I switched to GitHub and created a new repository there. Then executed
git remote add origin & lt; repository url & gt;
And when I tried push / pull, I got the same fatal: unrelated_histories
error.
And here’s how I fixed it:
git pull origin master --allow-unrelated-histories
git merge origin origin / master
... here we execute the add and commit commands ...
git push origin master