Reputation: 2080
I cleaned up my commit history yesterday because there was some private information that had accidentally been pushed. After cleaning my commits, I force pushed to my master branch. Everything is the same both on my computer and in my repo. However, when I try to push to Heroku I get this error:
Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g.'git pull ...') before pushing again.
So I have been looking through similar threads and have tried:
$ git pull origin master
and git pull --rebase origin master
which returns:
* branch master -> FETCH_HEAD
Already up-to-date.
I have also tried git fetch
which returns the same response. It says everything is up to date, so why can't I push to heroku? Does this have to do with the git filter-branch
I ran yesterday, and how do I fix it?
Upvotes: 2
Views: 1154
Reputation: 427
For this works.
heroku plugins:install heroku-repo
heroku repo:reset -a <yourappname>
git push heroku master
Upvotes: 0
Reputation: 4626
Git is designed in such a way that it will prevent you from overwriting any branches that have already been pushed to a remote. Your git filter-branch
is one of many ways of rewriting a branch's history (you got that part straight in your question).
The --force
option on git push
lets you update a remote branch regardless of any divergences in history.
Note that technically your private information is not guaranteed to be completely deleted.
dangling commits
git gc
over there.Upvotes: 7
Reputation: 2080
Well I haven't seen this before, but I figured I would give it a go:
git push --force heroku master
and what do ya know? It worked :)
Upvotes: 2