I\'m working on a team with a few developers using git on BitBucket. We are all working on a dev
branch, not pushing to master
until a release.
The error possibly comes because of the different structure of the code that you are committing and that present on GitHub. You may refer to: How to deal with "refusing to merge unrelated histories" error:
$ git pull --allow-unrelated-histories
$ git push -f origin master
I have done below steps. finally it's working fine.
1) git init
2) git status (for checking status)
3) git add . (add all the change file (.))
4) git commit -m "<pass your comment>"
5) git remote add origin "<pass your project clone url>"
6) git pull --allow-unrelated-histories "<pass your project clone url>"
master
7) git push -u "<pass your project clone url>"
master
You can try this: git pull origin master --rebase
This is how I solved this issue:
git pull origin master
git push origin master
This usually happens when your remote branch is not updated. And after this if you get an error like "Please enter a commit message" Refer to this ( For me xiaohu Wang answer worked :) )
You can override any checks that git does by using "force push". Use this command in terminal
git push -f origin master
However, you will potentially ignore the existing work that is in remote - you are effectively rewriting the remote's history to be exactly like your local copy.
Force to push
git push -f origin master