The objects folder in .git is extremely large for my small project

Mine git pushwas very slow, so I researched and found out that the folder .git/objectstakes ~ 450 MB.

The full project is only ~ 6 MB, but I added archives of 140 MB in size. Since github does not allow large files, I deleted them and then did git add -Aand tried to commit again, but it takes a lot of time and seems to load a lot.

Forever Required:

writing objects:  97% (35/36), 210.17 MiB | 49.00 KiB/s 

How to fix my git repository?

+1
source share
1 answer

Forever Records

Remember that Git saves all commits forever (don’t worry, there is a reason why this is done in quotation marks!).

, , , , , , : ", , , "... , " ". , "" . , "".

, ( ) ,

/ Git? , , , , GitHub ", ". , : - .

, , , git rebase -i - . , , git rebase -i:

pick a123456 add feature foo
pick b123456 rm giant file accidentally added in a123456
pick ...

( " " ) ( " " ) . , Git: " , , , , ". , , , , , remove-giant-file .

, "squash" "fixup" - , Git . pick squash fixup. , commit:

  • squash: , .
  • fixup: , , .

, . . rebase ( "BFG", , ) , , ( ), . , , , Git :

A--B--C--D--E   <-- master

, commit C , D, , E. , C -through- E ( E, ) , :

     C--D--E   [abandoned]
    /
A--B--C'--E'   <-- master

C-D-E C' ( C, D, ) E' ( E > ) master , E' E. , , , .

, . , , - C-D-E , , , . , C-D-E ! ( .)

C-D-E, , ( ). , ( ) C'-E'.

, , , :

pick a123456 add feature foo
pick b123456 rm giant file accidentally added in a123456
pick ...

, , "rm giant file" , , - . , " rm" , , rebase -i. : /; / , .

... , filter-branch BFG, () : . ( git commit --amend , , ).

+4

Source: https://habr.com/ru/post/1648168/


All Articles