1

My heroku repo grew to 1.5gb, so the nice fellows at heroku support cleared out the remote heroku repo and suggested I push a fresh copy.

However, the results of du -h .git locally show .git to be 276m. And, predictably, heroku throws an error when I try to push master to it.

So, my question: can I delete my local .git folder, do git init and push to heroku? What exactly would that do?

My app's code is pushed to github - my usual workflow is:

git add .
git commit -m "message"
git push #to github
git push heroku master
snowangel
  • 3,452
  • 3
  • 29
  • 72
  • 1
    That would kill your commit history. – SLaks Jun 27 '12 at 21:34
  • But what will that stop me doing? I don't have any collaborators, I have no need to ever rollback to a previous commit. All I care about is that my deployed app remains intact, plus its data. – snowangel Jun 27 '12 at 21:35
  • You could try "git gc" to compact the .git repository a little bit. http://www.kernel.org/pub/software/scm/git/docs/git-gc.html – Tomas Andrle Jun 27 '12 at 21:37
  • Yeah, have gc'd the life out of the the thing, and have also cloned my local repo as per http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big. No change... – snowangel Jun 27 '12 at 21:39
  • The rule of thumb is that a slug should be under 15MB for Heroku, with a maximum slug size of 200MB. https://devcenter.heroku.com/articles/slug-compiler – Todd A. Jacobs Jun 27 '12 at 22:01

4 Answers4

3

Possible Problems

There are two likely reasons your repository could be larger than expected.

  1. You have a lot of binary assets in your repository.
  2. You have a huge commit history.

Possible Solutions

If either of these things are the cause, you have a few options. Consider the following.

  1. If your problem is binary assets, move your assets to an external asset store (e.g. Amazon S3 or a remote filesystem). You can then remove them from your history with git-filter-branch followed by git-gc. This will slim down your repository a lot.

  2. If your problem is a really large history, make a separate shallow clone to push to Heroku. For example:

    git clone --depth 1 my_repo heroku_repo
    
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • The second one is the best solution. I liked it. – YuriAlbuquerque Jun 27 '12 at 22:16
  • Sorry it took so long to reply. The shallow clone idea worked nicely but now I'm pushing to my remote repo I get "fatal: attempt to push into a shallow repository". You can't push to or from a shallow clone: http://stackoverflow.com/questions/6900103/why-cant-i-push-from-a-shallow-clone – snowangel Jul 07 '12 at 12:30
0

Well, you couldn't do that, unless you force a push (which is almost never recommended). This would erase your whole commit history and create a brand new repository.

But if you WANT to erase everything because of space... you can. It's just... strange.

What happens if you only push master?

YuriAlbuquerque
  • 2,178
  • 1
  • 11
  • 19
  • Oh, I don't want to be strange. I just want to be able to push this code... Do you mean `git push master` rather than `git push heroku master`? – snowangel Jun 27 '12 at 21:40
0

You might want to do some housekeeping.

Usman
  • 2,325
  • 1
  • 23
  • 18
0

Do the upvoted answer but bear in mind that you can't push a shallow clone. Here's a follow up: Pushing to github after a shallow clone

Community
  • 1
  • 1
snowangel
  • 3,452
  • 3
  • 29
  • 72