There are certain scenario with Code repositories where you see the Error in the repository that says :
File Size is/or Exceeding 4GB, the repository will be readonly if it exceeds.
There are couple of steps to check & fix this issue :
-
Firstly, check the code repository if it contains some un-required and non-standard files being committed to the repository, it needs to be removed. Such as :
- Contributed modules
- Contributed themes
- Vendor directory
- Drupal Core
- .png, .pdf, .excel, .img, .png, .csv etc
-
Secondly, even after the above changes if the repository size is still exceeding and needs to be fixed. The issue lies in the git repository history, what it means is there might be some bigger files that were committed before which are not part of the current repository but exist in the git history. To look into which parts of the repository is taking the most space :
- Use the command
du -h
- Now, to fix the git history and remove occurrences of these unneeded history of files :
- Get the pack id of largest git objects and copy the file name from ‘.git/objects/pack’. The name should be something like : pack-7ab97afe1a6cd…..idx
- Now, to see the 10 biggest files, run this from the root directory :
git verify-pack -v .git/objects/pack/pack-7ab97afe1a….idx | sort -k 3 -n | tail -10
- To see what each file is, run this :
git rev-list —objects –all | grep [first few characters from the above output]
- Find the file type from the above that is taking the maximum space. Most of the files should be like .png, .mov, .csv and .pdf. The next step would be cleaning up the history for these file extensions.
- Repeat the command below for each file type in the same order :
- git filter-branch –index-filter ‘git rm –cached –ignore-unmatch *.mov’ –all
- rm -Rf .git/refs/original
- rm -Rf .git/logs/
- git gc –aggressive –prune=now
- Now, you can verify the size-pack which should be a lot smaller now by using one of the below methods :
- git count-objects -v
- du -h
References
Published on