4

Assume that I add a 1 GB movie in a git repository commit and push. Next I revert the commit that I just pushed and push that. Now latest head no longer contains the 1 GB file.

Even though I just reverted the commit is it correct that the 1 GB file is now permanently part of the git history? Meaning that even though I am working on the latest head without the 1 GB file the repo is still 1 GB larger and will remain that forever?

Roberto Tyley
  • 23,105
  • 11
  • 70
  • 100
u123
  • 14,161
  • 51
  • 160
  • 272
  • possible duplicate of [How to remove/delete a large file from commit history in Git repository?](http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – John Zwinck Dec 10 '14 at 08:49

1 Answers1

3

Even though I just reverted the commit is it correct that the 1 GB file is now permanently part of the git history?

Yes, the repo will remain big: a version control system is made to retain history.

You would need to filter its history and clean it (with git filter-branch or BFG) in order to reduce its size (and that would change its history)

Plus, as mentioned in "How to update/shrink the size of my github repo after running BFG Repo Cleaner", you would need after the filter:

git reflog expire --expire=now --all
git gc --prune=now --aggressive
Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • Is it possible to set a restriction on a git repo so its not possible to commit/push *.zip, *.dll files? Besides using .gitignore – u123 Dec 10 '14 at 12:52
  • @u123 you can put in place a pre-receive hook which will filter the list of files being pushed (as bit like in http://stackoverflow.com/q/2569960/6309) – VonC Dec 10 '14 at 13:54