NOTICE: This is never a recommended use of git. This will overwrite changes on the remote. Only do this if you know 100% that your local changes should be pushed to the remote master.
⚠️ Try this: git push -f origin master
As the error message says: git pull
before you try to git push
. Apparently your local branch is out of sync with your tracking branch.
Depending on project rules and your workflow you might also want to use git pull --rebase
.
I've just received this error.
I created a github repository after creating my local git repository so I needed to accept the changes into local before pushing to github. In this case the only change was the readme file created as optional step when creating github repository.
git pull https://github.com/*username*/*repository*.git master
repository URL is got from here on project github page :
I then re-initialised (this may not be needed)
git init
git add .
git commit -m "update"
Then push :
git push
use this command:
git pull --allow-unrelated-histories <nick name of repository> <branch name>
like:
git pull --allow-unrelated-histories origin master
this error occurs when projects don't have any common ancestor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With