Question

I wanted to undo a couple minor changes on my repo. I decided to go back two commits, and did

git reset --hard <commit>

and

git push -f

Everything went through fine. But when I pushed to heroku, I got an error about how some refs weren't pushed, and then this explanation:

Updates were rejected because the tip of your current branch is behind its remote counterpart. Merge the remote changes (e.g. 'git pull') before pushing again.

Every time I go back to a previous commit, I wind up with a detached HEAD or with the tip behind remote. This prevents me from pushing to git or heroku. Why? How do I get around this? What is the proper list of commands to follow so that this does not cause interference in the future?

Was it helpful?

Solution

I think that heroku is not allowing you to rewrite the history. When you are working on remote branches you shouldn't use reset or rebase. By using

git revert HEAD~2..HEAD

2 new commits will be created reverting the changes from the last 2 commits. This also prevents merging conflicts for your co-workers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top