Git says local branch is behind remote branch, but it's not
Solution 1:
You probably did some history rewriting? Your local branch diverged from the one on the server. Run this command to get a better understanding of what happened:
gitk HEAD @{u}
I would strongly recommend you try to understand where this error is coming from. To fix it, simply run:
git push -f
The -f
makes this a “forced push” and overwrites the branch on the server. That is very dangerous when you are working in team. But
since you are on your own and sure that your local state is correct
this should be fine. You risk losing commit history if that is not the case.
Solution 2:
The solution is very simple and worked for me.
Try this :
git pull --rebase <url>
then
git push -u origin master