1

I try to reduce my repo size and push it into a remote new-remote. What I tried is

  1. create a new branch by git checkout --orphan clean
  2. git rm --cached to clean those large file
  3. further cleaning ref by git reflog expire --expire=now --all followed by git gc --aggresive --prune=now.

I was hoping that in this way I only need to remove the large file in the HEAD since there's no history contained for this branch.However, after I did git push, I found the compressing object reduced but counting object remain the same. Could I know why this is the case, and which is a better indicator of whether the new-remote would have a shrinked repo ? Would git filter-branch be needed in my case ?

exteral
  • 991
  • 2
  • 12
  • 33
  • The numbers reported during `git fetch` and `git push` (object counts and the like) are not useful to humans, as far as I can tell. Ignore them. – torek Jan 16 '22 at 20:42

1 Answers1

1

If you start from scratch in a new orphan branch, I would then check the actual size of the repository by cloning the remote repository you just push to.

By cloning the remote in a new local folder, you would then get the actual size of your new repository.

But if that remote repository still includes all the other branches (and not just the new orphan branch), you would still get the large files in past commits.

I would then recommend to:

  • install git filter-repo (python-based)
  • delete any large file in your history: git filter-repo --strip-blobs-bigger-than 2M for instance. (content-based filtering)
  • force push (git push --mirror: make sure to notify any collaborator on that repository)
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • the `new-remote` would be an empty repo and I will push a clean branch into its master branch, would this work then ? Currently the push size is still large and takes long time and I have to stop it in the middle. For `git-filter-repo`, it seems will apply on all my branches ? – exteral Jan 17 '22 at 06:32
  • @exteral using a new empty repository will help. But if the initial push is still too big, that is when a `git filter-repo` is needed to prune any large file from the commit history. – VonC Jan 17 '22 at 06:39