How can I push my local repository to my remote when their files are completely unrelated?


Hey friends I’m new to git and I had a remote repo up on github that I put up there a while ago. It was a connect four game and recently I made a new one on my machine. Once I finished this new one I opened git bash and did git init. then I added and committed all my files. Then I did git add remote origin (then pasted the old remote repository url) and tried to push it and got this error

$ git push -u origin master
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘
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.

I then did get pull and got this

$ git pull
warning: no common commits
remote: Enumerating objects: 5, done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 5
Unpacking objects: 100% (5/5), done.

  • branch HEAD -> FETCH_HEAD
    fatal: refusing to merge unrelated histories

Any Ideas? Like I said I’m new to this and would appreciate a simple answer as I’m not that technical.


clone the old repo, delete everything, copy the new files in it.