Is there a way to reduce the size of the git folder?

后端 未结 7 1756
眼角桃花
眼角桃花 2020-12-12 09:44

Seems like my project is getting bigger and bigger with every git commit/push. Is there a way to clean up my git folder?

7条回答
  •  旧时难觅i
    2020-12-12 09:57

    Running this command is extremely dangerous, but will shrink your repository by erasing all your git recovery/backup files:

    git reflog expire --expire=now --all && git gc --prune=now --aggressive
    

    It will erase all files git uses to recover your repository from some bad command, for example, if you did git reset --hard, you can usually recover the files lost. But if you do git reset --hard before the git reflog expire... command, then you lost everything. Now, your only hope is to use some tool which analyses your file system and try to recover the erased files, if they were not overridden.

提交回复
热议问题