Last Updated: February 25, 2016
· codemangler

Take control of your Heroku Git repository

You can use the heroku-repo plugin to get raw access to the Git repo of your Heroku application.

Install the plugin by running:

$ heroku plugins:install

Once it's installed, you'll have a bunch of commands under the repo namespace.

Here's a few that I found useful:

  • Download the Git repo as an archive (useful when you can't clone from Heroku)
$ heroku repo:download -a appname
  • GC the repo (on Heroku)
$ heroku repo:gc -a appname
  • Reset the repo and upload an empty repo (my personal favourite :) )
$ heroku repo:reset -a appname

With this, you now have a way out when your Heroku repo gets messed up for any reason. You can just heroku repo:reset and start over :)

Another neat (but possibly useless) application of the plugin is to cleanly deploy an entirely different app into your existing Heroku instance, without leaving any dangling commits.

Let's start with a new Heroku application:

$ heroku create shell

Deploy an app into it

$ cd a-hip-app
$ git push shell HEAD:master

Now, you can cleanly deploy an entirely different app into the same instance after doing a repo:reset

$ heroku repo:reset -a shell
$ cd a-hipper-app
$ git push shell HEAD:master

There you go.

I think this should become part of the core Heroku toolbelt.
Check it out on GitHub: Also, I'd recommend that you look at it's source code to see how it works. It's just one file, and I thought it was pretty neat.

Read more

2 Responses
Add your response

Looks like the plugin isn't needed on Cedar repos. I just ran the command to GC without installing the plugin. :)

over 1 year ago ·

Neat. Didn't know this. Thanks for the update. :)

over 1 year ago ·