Reputation: 3615
I started a small project (10mb) and as it grew and produced output images it grew exponentially (to 12 gb). I realize I was uploading my images which are not part of the code. I removed them, added a rule not to upload images and kept commiting. Problem is now the code is still a few mb but the whole repository weighs 2 gb. I would like to revert or remove all the changes in the history where I uploaded images I mean every time I sent
new file: image.png
to the server it uploads the image, now I want to remove any trace of the images.
I am working in a brach on my own.
Can some one tell me how to do this?
Upvotes: 0
Views: 222
Reputation: 12617
You can use git filter-branch
. Github has a pretty good help page explaining the process of removing a file from the repository.
https://help.github.com/articles/remove-sensitive-data/
Upvotes: 0
Reputation: 142652
It can be done with git rebase -i
. it will open a dialog where you can alter every commit and remove the image from this commit
The side effect of rebase is that SHA-1 will be changes and if someone else already pulled out the branch it will become unusable for him, he will have to delete the branch and check it out again. so think twice before you do it.
git log --follow <file_name>
Read this post. It has a detailed explanation + sample code on how to do it.
Store big files in submodules so they will not be part of your base code
Upvotes: 4