Mistake:

$ git push form1 master To https://github.com/prochka/form-captchaNumber-ajax ! [rejected]
master -> master (fetch first) error: failed to push some refs to ' https://github.com/prochka/form-captchaNumber-ajax '

hint: Updates were rejected because

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: (eg, 'git pull ...') before pushing again.

hint: See the git push - help for the details.

The repository on GitHub has just been created and there are no changes.

  • git pull didn't help - Proshka
  • $ git pull form1 warning: no commits remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From github.com/prochka/form-captchaNumber-ajax + 4d2510c ... 9ee22b6 master -> form1 / master (forced update) you can’t specify a branch. This is not the default path configured for your current branch. - Proshka
  • $ git pull form1 master From github.com/prochka/form-captchaNumber-ajax * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories - Proshka
  • 2
    Additions to the question should be written in the question itself, and not in the comments. - insolor

2 answers 2

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, as you understand, these commits are not equal (the actual ones are just two different repositories).

Simply delete the .git folder locally, recreate the repository ( git init ), register upstream ( git remote add ... ) and after that you can do git pull . Should help :)

  • It may be worth adding a symmetrical option with clearing the repository on GitHub - mymedia
  • Many thanks for the help, everything helped, like in a fairy tale! - Proshka

Translation 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 <repository url> 

And when I tried to push / pull, I got the same fatal: unrelated_histories error. And this is how I corrected it:

 git pull origin master --allow-unrelated-histories git merge origin origin/master ... add and commit here... git push origin master