Reputation: 41
I've got a repo with about 2030 commits. At around commit 2000 a file was modified which caused it's size to travel from about 20M to 1.2 GB accidently. Is it possible to rewrite the history to remove this file but only from commit 2000? (I dont want to lose prior history of this file)
I was thinking git-filter-branch, but couldnt see a way to tell it the "from commit" - is it possible?
Cheers Mike
Upvotes: 4
Views: 289
Reputation: 25314
You might want to try the BFG Repo-Cleaner, a faster, simpler alternative to git-filter-branch
designed for removing large files or private data from Git repos.
Download the executable jar (requires Java 6 or above) and run this command:
$ java -jar bfg.jar --strip-blobs-bigger-than 100MB my-repo.git
Anything over 100MB in size (that isn't in your latest commit's file hierarchy) will be totally removed from your repository's history. All the versions of the file which are smaller than 100MB will be left alone, as specified in the question.
Full disclosure: I'm the author of the BFG Repo-Cleaner.
Upvotes: 1
Reputation: 33643
Why won't you
new
at commit 2000, where you don't modify this file to a 1.2 GB filemaster
to new
, with merge option -Xtheirs
Upvotes: 1
Reputation: 393769
The man page for git-filter-branch contains the conclusive and authoritative example for this.
If you want to stop rewriting before a certain commit, say before tag01
:
git-filter-branch ...... -- master ^tag01
Substitute what you already have for the dots. tag01 may instead be any commit-ish (revspec)
PS: if you use tags don't forget --tag-name-filter cat
to rewrite these too
Upvotes: 2