tags:

views:

155

answers:

2

During late development of an application I've been git pushing to heroku such that the repository there is fairly large.

I would like at this stage, before site launch, to remove all old versions from the repo as it seems sensible housekeeping. What would be the best way to go about this so my online application be uninterrupted?

+1  A: 

There is really no need to do this for Heroku specifically, as when you push, it compiles your app into a slug for quick deployment, and one step of that is dropping the git repo entirely.

But if you really want to do this, I'd suggest just deleting the .git/ directory from your project and starting a new repo with git init.

Heroku acts just like any other git remote you can push to, so anything you can do to a normal git remote, you can do to your Heroku git remote. So if you push a new, empty repo to it, that should solve your problem for sure.

tfe
Hi tfe and thanks for your reply. My fairly limited experience tells me this won't work and that I'll receive a non fast forward rejected message. As for this being worthwhile, well I thought there was a maximum heroku repo size - though I can't find such info now - that I would meet at some time and as such now would be a good time to clear it. Additionally, a backup strategy I have involves regularly emailing projects to mail account and the repository makes this a more lengthy process.
mark
You can get around the non-fast-forward thing by just saying `push -f`. You'll only have to do that once, and then subsequent pushes will be normal. I still think dropping the .git folder and re-creating as a new repo is the best way to drop your existing history.
tfe
That allowed me to push a newly initialized repo but it's merged my repo with heroku's which is the same size as before.
mark
You could simply delete the entire app on heroku and create a new one. Obviously make sure you have a copy of the database too.
Joost Schuur
Hi Joost. I'd rather not have to set up everything again and have any downtime, though the thought had crossed my mind.
mark
Heroku acts just like any other git remote you can push to, so I don't know why creating a new empty repo and force pushing it would not work.
tfe
You're right. Other funky stuff going on with my application caused me to have doubts and heroku's repository still displays the previous large size but the git log seems ok. btw editing your answer even a little will allow me to upvote you. Thanks!
mark
Haha, okay done. Thanks.
tfe
+1  A: 

Use gitignore for stuff you don't actually use and ensure all images etc are on s3, keep your slug small as small as pos is the first issue. Heroku will restart you app on upload so you can't avoid the downtime issue (would love to be corrected on the downtime thing), been a while since I used heroku.

dryprogrammers