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

后端 未结 7 1745
眼角桃花
眼角桃花 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条回答
  • 2020-12-12 10:21

    One scenario where your git repo will get seriously bigger with each commit is one where you are committing binary files that you generate regularly. Their storage won't be as efficient than text file.

    Another is one where you have a huge number of files within one repo (which is a limit of git) instead of several subrepos (managed as submodules).

    In this article on git space, AlBlue mentions:

    Note that Git (and Hg, and other DVCSs) do suffer from a problem where (large) binaries are checked in, then deleted, as they'll still show up in the repository and take up space, even if they're not current.

    If you have large binaries stored in your git repo, you may consider:

    • managing those binaries in an external repository.
    • manage your .git repo size
    • try and remove those binaries from your history with git filter-branch (warning: this will rewrite the history, which is bad if you have already pushed your repo and if other have pulled from it)

    As I mentioned in "What are the file limits in Git (number and size)?", the more recent (2015, 5 years after this answer) Git LFS from GitHub is a way to manage those large files (by storing them outside the Git repository).

    0 讨论(0)
提交回复
热议问题