When you already have some thing in your git repo for example you created a git repo on github with readme file and then tried to push your local code first time to that github repo.
So github repo already has a commit, it will force you to first pull it to your local code before pushing your local code up.
When you issue a pull request it comes with “fatal: refusing to merge unrelated histories”
So before pushing your code to git, first pull it with allowing unrelated history, i.e issue the pull request with –allow-unrelated-histories
$ git pull origin master --allow-unrelated-histories