Converting git repository to shallow?

This worked for me:

git pull --depth 1
git gc --prune=all

This leaves the tags and reflog laying around, each of which reference additional commits that can use up space. Note that I would not erase the reflog unless severely needed: it contains local change history used for recovery from mistakes.

There are commands on how to erase the tags or even the reflog in the comments below, and a link to a similar question with a longer answer.

If you still have a lot of space used you may need to remove the tags, which you should try first before removing the reflog.

Leave a Comment