Convert to LFSFor repositories that have reached the
1GBlimit it is necessary to move large files already in the repository to LFS. Simply deleting files is not enough as these are still present in previous revisions.
Before You BeginMake sure nobody is interacting with the repository and that all local changes are committed. There is not way to enforce this on GitLab so you need to communicate this to everybody who can make changes. Also, make an additional backup of the repository as it was before the conversion using this command:
git clone --mirror email@example.com:<group>/<project>.git /some/path/<project>.git.backup-before-lfs'
Install LFSLFS needs to be installed into a repository using this command:
cd <repository> git lfs install
Enable Tracking by File ExtenstionLFS identifies files to be put in LFS by the file name extension. Run the following command to add the most common extensions for large files that should be placed in LFS:
for ext in bin exe jar dmg pkg apk deb rpm msi msu zip rar 7z tar tar.gz tgz gz bz2 xz cab mp4 m4v mkv flv wmv ogv avi mov mp3 m4a m4r au ogg wav wma raw iso img do git lfs track "*.$ext" done
Migrate to LFSMigrate all files matching the tracked file extensions with this command:
git lfs migrate import --everything --object-map commit-map
Prepare for PushGot to Settings » Repository of the project at https://gitlab.inf.ethz.ch and under Protected branches enable Allowed to force push for all entries.
PushPush the changes made by enabling LFS and importing files to LFS:
If the push is successful then revert all Allowed to force push changed in the previous step again.
git add .gitattributes git commit -m "move large files to LFS" git push --force
Free SpaceExecute a repository cleanup by navigating to Settings » Repository and expanding Repository cleanup. This requires a
commit-mapbut the file create with
git lfs migrateis not compatible with GitLab. All commas must be replaces with space. Use a text editor or run the following command:
Start the cleanup with the altered
sed -i -e 's/,/ /' commit-map
commit-map. If the space is not shortly freed after this then you may need to wait 30 minutes and try again. Once the space is freed the file
commit-mapcan be deleted.