Can't push after repo clean-up for large files | error: failed to push some refs to 'gitlab.com:my-repo.git'
I am stuck for 2 days trying to find a way to clean up my remote gitlab
repo. I mistakenly push local repo after adding my data folder, which I forgot to include in the git-ignore. Since then, I cannot push any more, as the remote grows to 9.8GB
, so I kept getting exceeded storage error.
I then completely removed the data folder fom my git-tracked repo. The resulting local repo is now about 12M
size (python scripts and jupyter notebooks) only. Despite this clean-up, yet I cannot push to remove.
I followed the procedure outlined here.
- Cloned a fresh copy of my repository from using --mirror flag:
$ git clone --bare --mirror my-repo.git
Cloning into bare repository 'my-repo.git'...
remote: Enumerating objects: 1306, done.
remote: Total 1306 (delta 0), reused 0 (delta 0), pack-reused 1306
Receiving objects: 100% (1306/1306), 9.73 GiB | 14.86 MiB/s, done.
Resolving deltas: 100% (232/232), done.
- Use BFG to clean my repository up:
$ java -jar bfg.jar --strip-blobs-bigger-than 100M my-repo.git
Using repo : ~/Desktop/my-repo.git
Scanning packfile for large blobs: 1306
Scanning packfile for large blobs completed in 122 ms.
Found 44 blob ids for large blobs - biggest=4510353716 smallest=139891564
Total size (unpacked)=25557013908
Found 101 objects to protect
Found 2 commit-pointing refs : HEAD, refs/heads/master
Protected commits
-----------------
These are your protected commits, and so their contents will NOT be altered:
* commit f1182758 (protected by 'HEAD')
Cleaning
--------
Found 53 commits
Cleaning commits: 100% (53/53)
Cleaning commits completed in 149 ms.
Updating 1 Ref
--------------
Ref Before After
---------------------------------------
refs/heads/master | f1182758 | 0dfb315a
Updating references: 100% (1/1)
...Ref update completed in 24 ms.
Commit Tree-Dirt History
------------------------
Earliest Latest
| |
..............DmmmmmDDDDmmmDDDDDDDDDDDDDDDDmmmmmmmmmm
D = dirty commits (file tree fixed)
m = modified commits (commit message or parents changed)
. = clean commits (no changes to file tree)
Before After
-------------------------------------------
First modified commit | fc7cf2f9 | 16fc0a12
Last dirty commit | d4a1a3d4 | 8e1c1db0
Deleted files
-------------
Filename Git id
-------------------------------------------------------------------------------------------------------------------------
3Class_Instances.pkl | ceebb395 (558.1 MB)
Beijing_KerasData.pkl | 8681a270 (133.4 MB)
Filtered_Trajectory.pkl | bfe06d09 (137.8 MB)
Foot_Car_Instances.pkl | c4bea045 (537.3 MB)
Foot_Car_Instances2.pkl | 8d9b96ad (537.3 MB)
Instance_Geolife.pickle | ee16e13b (412.5 MB)
Instance_Geolife_Beijing.pkl | c2cd394a (409.6 MB)
RF_modelGeolife.h5 | 5629ee4d (146.7 MB)
RF_modelSMF.h5 | 14372982 (249.3 MB)
RF_modelgeolife.h5 | 36293e2c (146.7 MB)
Revised_InstanceCreation+NoJerkOutlier+NOSmoothing.pickle | 29ff8dd4 (269.6 MB)
Revised_KerasData_NoSmoothing.pickle | 775b6041 (1.5 GB)
Revised_Trajectory_Label_Array2017.pickle | 7e24d6f7 (216.7 MB)
Revised_Trajectory_Label_Array2018.pickle | cee1e176 (791.3 MB)
SMF2016_3W_1W.pkl | 2acd469b (400.0 MB)
...
In total, 70 object ids were changed. Full details are logged here:
~/Desktop/my-repo.git.bfg-report/2021-11-23/09-21-13
BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive
- And changed to cloned repo:
$ cd my-repo.git
$ git reflog expire --expire=now --all && git gc --prune=now --aggressive
Enumerating objects: 1306, done.
Counting objects: 100% (1306/1306), done.
Delta compression using up to 8 threads
Compressing objects: 100% (1242/1242), done.
Writing objects: 100% (1306/1306), done.
Building bitmaps: 100% (53/53), done.
Total 1306 (delta 243), reused 963 (delta 0), pack-reused 0
However, after doing this, I cannot push:
$ git push
$ git push
Enumerating objects: 1306, done.
Writing objects: 100% (1306/1306), 2.16 GiB | 13.90 MiB/s, done.
Total 1306 (delta 0), reused 0 (delta 0), pack-reused 1306
remote: Resolving deltas: 100% (243/243), done.
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To gitlab.com:my-repo.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'gitlab.com:my-repo.git'
How do I solve this?
Edited by Maryam Umar