The situation is as follows:
We have some project which persists on Github, and deploy it to Heroku, which has its own mini-Git. Some changes were applied directly to Heroku (cloned repository from Heroku, made changes and pushed). In a meanwhile the master branch on Github has gained also some changes.
Now when I want to push the main repository to Heroku, pushing fails because commits on Heroku are out of sync with local commits.
I do not want to merge with changes on Heroku - I just want them to vanish.
Is there some way to clean git repository on Heroku to push then my local repo from the very beginning?
I do not want to destroy application and recreate it again because it has some paid services and I am just an collaborator.
Install the Heroku Repo plugin and use it to reset the remote git repo.
First delete the git repo on the server:
> cd /my-project/ > heroku plugins:install heroku-repo > heroku repo:reset
Then re-initialise your local git repo by deleting and recreating it:
> cd /my-project/ > rm -rf .git > git init > heroku git:remote -a <appname>
Where <appname>
is name of your app in heroku.
The 2 repos (local and remote) should now be empty and in sync.
You can just use the -f
flag in git (it's a standard git flag) to force the push. See the side note in the Dev Center Git doc. This will overwrite those changes you've made on Heroku obviously.
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