-2

Earlier I pushed some big files to git branch which increased the repository size. Later I removed those redundant files from that branch using,

git rm big_file
git commit -m 'rm bg file'
git push origin branch-name

But the file size of git repository remained unchanged.

Then I tried using this method to clear commit history but it didn't worked, the repo size is still the same.

Swapnil Masurekar
  • 458
  • 1
  • 9
  • 21
  • 1
    Similar question: https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository?noredirect=1&lq=1 – k0pernikus Jan 06 '20 at 09:45
  • Also, try using git-lfs in the future : https://git-lfs.github.com/ – fdrobidoux Jan 06 '20 at 19:08

2 Answers2

4

You have deleted the big file only from the last commit, you will need to delete it from earlier commits as well, otherwise, your repository size will not be reduced.

You should use this tool to clean your repository history:

https://rtyley.github.io/bfg-repo-cleaner/

It the prefect tool for this kind of task.

BFG Repo-Cleaner

an alternative to git-filter-branch.

The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:

  • Removing Crazy Big Files
  • Removing Passwords, Credentials & other Private data

Examples (from the official site)

In all these examples bfg is an alias for java -jar bfg.jar.

# Delete all files named 'id_rsa' or 'id_dsa' :
bfg --delete-files id_{dsa,rsa}  my-repo.git

enter image description here

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • I have already tried [this](https://stackoverflow.com/a/26000395/11652623) so the earlier commits have been cleared which contained the big file, even filter-branch try to rewrite only the current commits of orphan branch – Swapnil Masurekar Jan 06 '20 at 10:06
1

This Atlassian Document works more or less the same with all git products: https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html It includes BFG and git filter branch methods together. I've previously used both BFG and filter branch methods . BFG works fine. This documentation also helps to avoid such type of commits https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html

nur.zardic
  • 29
  • 6