Keith Johnson
Keith Johnson

Reputation: 730

How do I reset to my source code on heroku?

I've deployed an app to heroku and want to reload that source code and work from there again and blow away all changes I've made since. Is there a way to do a git reset --head [heroku-source]? I know I can get the source with a heroku git:clone -a myappbut I would like to know if there's a more efficient way.

After I pushed to Heroku, I kept making changes and never pushed to Git. So my cleanest code is there.

Upvotes: 0

Views: 1761

Answers (2)

georgebrock
georgebrock

Reputation: 30083

I'm assuming your changes are all on the master branch, and you have that branch checked out before you start.

  1. Make sure you have a Heroku git remote:

    heroku git:remote
    
  2. Check out a new branch, so that you don't lose your changes if something goes wrong:

    git branch recent-changes
    
  3. Fetch from the Heroku remote, this will create or update a remote tracking branch called heroku/master that contains the current state of the master branch on Heroku:

    git fetch heroku
    
  4. Look at what's changed between master and heroku/master, and make sure you really want to throw those changes away:

    git log heroku/master..master
    
  5. Reset your local master branch back to wherever the heroku/master branch is up to:

    git reset --hard heroku/master
    

Upvotes: 1

Ju Liu
Ju Liu

Reputation: 3999

You can simply

git reset --hard heroku/master

where heroku is the name of the heroku remote origin. You can view your remote branches with

git branch -r

Upvotes: 1

Related Questions