Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to purge some files from the history of git?

I have migrated a couple of project from Subversion to git. It work really well but when I clone my repository, it's really long because I have all the history of a lot of .jar file included in the transfer.

Is there a way to keep only the latest version of certain type of file in my main repository. I mainly want to delete old version on binary file.

like image 717
mathd Avatar asked Sep 18 '08 20:09

mathd


2 Answers

You can remove old versions with either "git rebase" -i or "git filter-branch"

http://schacon.github.com/git/git-filter-branch.html

http://schacon.github.com/git/git-rebase.html

Other docs and tutorials: http://git-scm.com/documentation

Keeping only the current version from now forward is not supported. Your best bet is to instead keep in revision control a small script that downloads (or builds, or otherwise generates) the large .jar file.

As this modifies history, it will make all previous clones or pulls from this repository invalid.

like image 77
wnoise Avatar answered Sep 19 '22 10:09

wnoise


In short, this would involve rewriting the entire git commit tree to exclude the files. Have you tried using git gc and git pack to have git compress your repository?

like image 32
Martin OConnor Avatar answered Sep 19 '22 10:09

Martin OConnor