-2

We have changed from SVN to GIT ( bitbucket ) a few months ago, now we are recieving a warning that our git repository is becomming to large ( currently at 2.2GB ). However when i check the local size our project is only +- 600MB in size. This is a project that has been in development for over 6 years so there are many commits ( history ) especially files like .jar viles that got added, and than back deleted to be replaced with newer versions etc. They don't exist on our current project anymore, but they are still in the git history where they take up space that isn't needed because we won't ever use them again, i'm looking for a way to remove all deleted files that don't exist in the current project and remove them completely from the git commit history ( not all files that ever got deleted ). I know that there is the 'git-filter' command to remove a file from the commit history but as far as i can see you have to specify wich file to be remove while i have no idea how many / wich files got deleted over the years in our project.

  • 1
    Does this answer your question? [How to remove/delete a large file from commit history in the Git repository?](https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-the-git-repository) (Note that some of the answers there are quite old; read through for newer tools that may be easier to use.) – IMSoP Apr 07 '22 at 09:08

1 Answers1

3

You can use the command git filter-branch

git filter-branch --index-filter \
    'git rm -rf --cached --ignore-unmatch path_to_file' HEAD

Be careful because you will rewrite the history of your deposit

j6t
  • 9,150
  • 1
  • 15
  • 35
Brinfer
  • 398
  • 1
  • 10
  • But this command will only remove one specific file / directory? or what are you supposed to be filling into path_to_file? – WhyDoYouDie Apr 07 '22 at 08:08
  • You can put a file type: `*.extension`. A folder: `folder/` A specific file: `path/to/file`. In fact you can put the same elements that are in the `.gitignore` – Brinfer Apr 07 '22 at 09:08