Getting an error pushing to github – Updates were rejected because a pushed branch tip is behind its remote

If you don’t care about what’s currently in repo2 and are confident that totally overwriting it is ok then you can use:

$ git push -f [email protected]:<heroku repo name>.git

Remember though that push -f can wipe out other developers changes if they were posted since you last pulled from the repo… so always use with extreme caution on multi-developer teams!
In this case heroku is always downstream and github is where the code is managed and maintained so this makes push -f on heroku a safer option that it would otherwise be.

Leave a Comment