Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean git repo on Heroku

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.

like image 992
Paul Avatar asked May 04 '12 14:05

Paul


2 Answers

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.

like image 186
Steve Eynon Avatar answered Sep 28 '22 09:09

Steve Eynon


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.

like image 33
Jon Mountjoy Avatar answered Sep 28 '22 07:09

Jon Mountjoy