학문의 길/Git

LFS 기존 Commit 로그 제거하기 (BFG Repo-Cleaner)

lipnus 2022. 12. 26. 23:45
반응형

Problem

 

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v --tags --set-upstream origin dev:dev
Pushing to https://github.com/lipnus/cfd.git
POST git-receive-pack (chunked)
remote: warning: File Assets/Firebase/Plugins/x86_64/FirebaseCppApp-10_3_0.so is 75.83 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB        
remote: warning: File Assets/Plugins/iOS/Firebase/libFirebaseCppFirestore.a is 62.25 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB        
remote: error: Trace: 12e54aed7592073c9adc6758719bfaad29783cc0b269203618454f5b293eb268
remote: error: See http://git.io/iEPt8g for more information.        
remote: error: File Assets/Firebase/Plugins/x86_64/FirebaseCppApp-10_3_0.bundle is 137.45 MB; this exceeds GitHub's file size limit of 100.00 MB        
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.        

To https://github.com/lipnus/cfd.git
 ! [remote rejected]     dev -> dev (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/lipnus/cfd.git'

 

위와 같은 에러가 난 경우,

기존에 50M가 넘는 커밋을 이미 올린 경우라면

git-lfs등 뭔 짓을 해도 해당 커밋을 수정하기 전까지 동일한 에러가 발생.

 

본인의 경우 Libaray Dependancy 관련 Commit 이 켜켜히 쌓여있어 수정하기가 힘든 상황

 

Solution

BFG Repo-Cleaner — BFG Repo-Cleaner https://rtyley.github.io/bfg-repo-cleaner/ — 를 이용

 

java -jar bfg-1.14.0.jar --strip-blobs-bigger-than 50M

 

lipnus@LAPTOP-DVOR8J7G MINGW64 /d/dev/CFD (develop)
$ java -jar bfg-1.14.0.jar --strip-blobs-bigger-than 50M

Using repo : D:\dev\CFD\.git


This repo has been processed by The BFG before! Will prune repo before proceeding - to avoid unnecessary cleaning work on unused objects...

Completed prune of old objects - will now proceed with the main job!

Scanning packfile for large blobs: 68553
Scanning packfile for large blobs completed in 429 ms.
Found 15 blob ids for large blobs - biggest=926343223 smallest=53396332
Total size (unpacked)=2000134129
Found 15639 objects to protect
Found 8 commit-pointing refs : HEAD, refs/heads/ad, refs/heads/develop, ...

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit 3b7a7a4c (protected by 'HEAD') - contains 10 dirty files :
        - Assets/Basecamp/School/ground.fbx (71.6 MB)
        - Assets/CFD/Unit/Chamsuri/Model/Chamsuri Class fbx.fbx (53.5 MB)
        - ...

WARNING: The dirty content above may be removed from other commits, but as
the *protected* commits still use it, it will STILL exist in your repository.

Details of protected dirty content have been recorded here :

D:\dev\CFD.bfg-report\2022-12-26\23-33-14\protected-dirt\

If you *really* want this content gone, make a manual commit that removes it,
and then run the BFG on a fresh copy of your repo.


Cleaning
--------

Found 320 commits
Cleaning commits:       100% (320/320)
Cleaning commits completed in 867 ms.

Updating 4 Refs
---------------

        Ref                           Before     After
        -------------------------------------------------
        refs/heads/ad               | 4f615f88 | fef0b7bf
        refs/heads/develop          | 3b7a7a4c | 98975c5d
        refs/remotes/origin/develop | 1e6e83c6 | 2c5aaaaa
        refs/stash                  | ae4ef72f | cd0d126c

Updating references:    100% (4/4)
...Ref update completed in 21 ms.

Commit Tree-Dirt History
------------------------

        Earliest                                              Latest
        |                                                          |
        DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

        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 | 2de9a521 | b0fbdc63
        Last dirty commit     | ae4ef72f | cd0d126c

Deleted files
-------------

        Filename                                                Git id         
        ---------------------------------------------------------------------------
        Chamsuri Class fbx.fbx                                | 09bfacb5 (53.5 MB)
        FirebaseCppApp-10_3_0.bundle                          | f0c4e34e (137.4 MB)
        FirebaseCppApp-10_3_0.so                              | 741d1cbc (75.8 MB)
        FirebaseCppApp-7_2_0.so                               | 67d681fe (98.4 MB)
        FishingBoat2_specular.tif                             | 2502b0d8 (64.0 MB)
        HoseWater_TextureSheet.tif                            | a3676acc (64.0 MB)
        RescueBoat_Main_MetallicSmoothness.tga                | 0d907d00 (64.0 MB)
        SmallSplash_Ripples_TextureSheet.tif                  | 1cae1bf7 (64.0 MB)
        Terrain_01_low_DefaultMaterial_AlbedoTransparency.png | c8124742 (73.8 MB)
        Terrain_01_low_DefaultMaterial_Normal.png             | 55b0abd7 (80.3 MB)
        Water_Drop_Texturesheet.tif                           | a90726f3 (64.0 MB)
        ground.fbx                                            | 9716400c (71.6 MB)
        libFirebaseCppFirestore.a                             | cb7d4024 (62.2 MB)
        reckoning.wav                                         | 7d2504e6 (50.9 MB)


In total, 1379 object ids were changed. Full details are logged here:

        D:\dev\CFD.bfg-report\2022-12-26\23-33-14

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive

 

 

기존 커밋들에서 50M가 넘는 로그들을 싸악 정리해준다.

 

주의

이미 Push했던 Commit의 로그도  진부 정리해버림.

= 원격저장소와 로컬의 Commit History가 완전히 어긋나버림.

= 이전에 LFS를 설정해서 50M이상의 파일을 올린 적이 있는경우 git이 완전히 아작남

 

 

 

 

https://medium.com/@stargt/github%EC%97%90-100mb-%EC%9D%B4%EC%83%81%EC%9D%98-%ED%8C%8C%EC%9D%BC%EC%9D%84-%EC%98%AC%EB%A6%AC%EB%8A%94-%EB%B0%A9%EB%B2%95-9d9e6e3b94ef

 

Github에 100MB 이상의 파일을 올리는 방법

문제점

medium.com

 

반응형

'학문의 길 > Git' 카테고리의 다른 글

Unity Github Action  (0) 2024.07.17
reset 한거 취소하는 방법  (0) 2019.10.31
브렌치(Branch)  (0) 2019.04.10