Make Git consume less disk space?

后端 未结 11 933
鱼传尺愫
鱼传尺愫 2020-12-24 05:19

What is the best way for git to consume less disk space?

I\'m using git-gc on my repositories (which does help, especially if there have been many commits since it w

11条回答
  •  悲&欢浪女
    2020-12-24 05:46

    There are a few suggestions I can offer:

    1. Delete no longer used branches. They can pin some commits that you don't use and would never use. Take care however to not delete branches that you would later need (perhaps for review, or for comparison of failed effort). Backup first.

    2. Check if you didn't commit some large binary file (perhaps some generated file) by mistake. If you have, you can purge it from history using "git filter-branch"... well, if you didn't share the repository, or it is worth aggravating other contributors to rewrite history. Again: backup first.

    3. You can prune more aggressively, discarding some safeties, bu using git gc --prune=now, or low-level git prune. But take care that you don't remove safeties and backups (like reflog) that you need minute after compacting.

    4. Perhaps what enlarges your repository are some untracked files in working directory. There "make clean" or "git clean" might help (but take care that you don't remove some important files).

    5. Most safe of all those suggestions: you can try to pack more aggressively, using --depth and --window option of low-level git-repack. See also Git Repack Parameters blog post by Pieter de Bie on his DVCS Comparison blog, from June 6, 2008. Or "git gc --aggressive".

提交回复
热议问题