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
  • 24,513
  • 11
  • 72
  • 101
u123
  • 15,603
  • 58
  • 186
  • 303
  • 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,262,500
  • 529
  • 4,410
  • 5,250
  • 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