tags:

views:

61

answers:

3

My central repository is stored on an 8GB USB stick. I accidentally committed some big files, so the repository doesn't fit on the stick anymore. Is there a way to correct this situation?

A: 

Never ever store such important thing as a code repository on a USB stick. That's an invitation to loose all your code very soon! Buy an external HDD with enough space and at least 2 separate disks inside, which you can mirror. Store it permanently somewhere and don't carry it around. If you need access from other place - use a secure internet connection to access your HDD remotely.

m_pGladiator
In my setup, I have at least 2 copies: one on my PC's hard drive and one on the USB stick. Each of these can serve as a backup. I find this sufficient.
Dimitri C.
The code is yours (as well as the choice) :) I've experienced an electric peak, which burned my PC, including the internal HDD, and everything connected on the USB ports, including one USB stick...
m_pGladiator
+4  A: 

You can rollback the last commit with the big files, if the commit really accidental. See

hg help rollback

Of course, this doesn't work if you committed other important stuff on top in the meantime. Another way would be to use strip to remove the whole branch containing the big files.

Be careful, before you perform any of these operations, make sure you understand what you're doing! Test the commands first on a test repository or clone.

catchmeifyoutry
+4  A: 

I voted up catchyifyoutry's answer since he's got the steps you'll probably use, but here's a handy list.

First, though, a reminder. If you've already pushed this repository somewhere semi-public, and people have pulled the repository, then none of the tips below will work. When next they push and you pull you'll get the original changesets back in their unmodified form. Your only recourse is to talk to each person who has a clone and ask them to delete it and re-clone. That said, on to the list:

Ways to obliterate files you committed on accident

  • If you've not yet pulled or committed anything else: hg rollback will act as one level undo
  • If you're willing to throw away the last N revisions: hg clone -r -N repo-with-too-much repo-with-N-fewer changesets # example: hg clone -r -2 big-repo small-repo
  • If your change was too long ago for either of those to be okay: hg convert --filemap myfilemap.txt too-big-repo new-repo

In that last case myfilemap.txt has in it:

exclude path/to/file/to/remove

Notes:

  • the clone -r case technically asks for the minimal clone that could include revision tip-N, which if you have a branchy repo. Additionall pull -r lines (one per head) will be necessary to pull over other non-linear history.
  • with the hg convert solution the hashcode of every modified changeset and all of their descendants will be modified.
Ry4an
That --filemap trick sounds like exactly what I need. Although a little cumbersome, this should be necessary in exceptional cases. Thanks a lot!
Dimitri C.