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?
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
hg rollback
will act as one level undohg clone -r -N repo-with-too-much repo-with-N-fewer changesets
# example: hg clone -r -2 big-repo small-repo
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:
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.hg convert
solution the hashcode of every modified changeset and all of their descendants will be modified.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With