Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you remove big files from history in mercurial?

I have just created a mercurial repo created from a heterogeneous ecosystems of other repos. Before I publish it to my co-workers, I want to clean it as much as possible. To this end, I'd like to entirely remove a few big old files from history (pretend they never existed), so repo will be smaller.

Is this possible with mercurial?

like image 429
static_rtti Avatar asked Apr 11 '12 09:04

static_rtti


People also ask

How to delete files Mercurial?

Once you decide that a file no longer belongs in your repository, use the hg remove command. This deletes the file, and tells Mercurial to stop tracking it (which will occur at the next commit). A removed file is represented in the output of hg status with a “ R ”.

How to untrack files in hg?

If you see the help for hg rm --help : hg remove [OPTION]... FILE... Schedule the indicated files for removal from the current branch. This command schedules the files to be removed at the next commit.


1 Answers

Check out the convert extension, particularly the --filemap option.

Enable by adding the following to mercurial.ini:

[extensions] convert = 

Create a map of files to exclude:

exclude path/to/file1 exclude path/to/file2 

Then convert the repo:

hg convert srcrepo destrepo --filemap <map> 

Note there is a bug in Mercurial 2.1.1 causing an error with the above command:

initializing destination destrepo repository abort: invalid mode ('r') or filename 

Just add the --splicemap <nonexistent file> option to fix the problem.

like image 133
Mark Tolonen Avatar answered Sep 24 '22 14:09

Mark Tolonen