Sirac
Sirac

Reputation: 93

Why gitlab Storage is quite bigger than downloaded with git clone?

Due to old unused files, my repo was very big (1.4GB). So I decided to clean it with bf. After a push and clone agin, a du -sh in my local project give me 70Mo, so it's fine.

But, on my gitlab GUI, the repos is still very big (1.3Go) as you can see here:

enter image description here

I have tried to start an house keeping task in settings, but no change. Have you an idea of how i can reduce the size?

Upvotes: 1

Views: 1823

Answers (1)

Andy
Andy

Reputation: 50540

You've performed the first steps in GitLab's recommendations. The steps below are from their documentation on how to purge files from GitLab storage.

This is going to be a destructive action. You are rewriting repository history.

  1. Install git filter-repo

  2. Generate an export from the project

  3. Download the export from step 2.

  4. Decompress the export: tar xzf backup.tar.gz This will contain a project.bundle which was created by git bundle

  5. Clone a fresh copy of the repository from the bundle: git clone --bar --mirror /path/to/project.bundle

  6. Using the previously install git filter-repo, purge any files from the history of your repository. GitLab provides a couple example commands.

     To purge all large files, you will want to use `--strip-blobs-bigger-than`. This example reports files larger than 10 megabytes: 
     `git filter-repo --strip-blobs-bigger-than 10M`
    
     To purge specific files by path, you can combine both `--path` and `--invert-path`:
     `git filter-repo --path path/to/large.mp4` --invert-paths
    
  7. Cloning from the project.bundle sets the origin remote to the local bundle file. This is not wanted, so delete this origin remote and reset it to your repository.

     git remote remove origin
     git remote add origin http://gitlab.example.com/<namespace>/<repository>.git 
    
  8. Force push the changes to the repository. This will overwrite all branches. If you have protected branches, you will need to remove branch protection first, run the command below, then re-enable protected branches.

     git push origin --force 'refs/heads/*'
    
  9. If you have large tagged releases, you also need to force push changes to all tags. If you have protected tags, you will need to remove tag protection first, run the command below, then re-enable protected tags.

     git push origin --force 'refs/tags/*'
    
  10. Prevent dead links to commits that were removed, run the following:

    git push origin --force 'refs/replace/*'
    
  11. Within your repository project page, navigate to Settings->Repository

  12. Upload a commit-map created by the git filter-repo command. GitLab restricts this to 10M per file, but you can split it and upload piece by piece if needed.

  13. Click Start Cleanup

Upvotes: 1

Related Questions