Permanently clean up the history of large files in git

Original Posted: https://www.chenxublog.com/2019/05/26/remove-git-big-files.html

Write the old git repository, because of ignorance of the year, will not be used .gitignore, under the residual image debug, objsuch as a directory of files, very space, then we need to history in various garbage clean-up

The first step of course is to open git bash (linux can ignore)

To determine where a certain file or a path, you want to permanently clean out of

If it is a directory, execute:

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch obj/*' --prune-empty --tag-name-filter cat -- --all

If the expansion is the name of a file, such as lod:

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.lod' --prune-empty --tag-name-filter cat -- --all

And then do the following things in order, clean up the space like:

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

Finally force pushing up the cloud cover, the push belt command line --force --allparameters can, TortoiseGitrefer to the following:

Slimming spicy complete git repository

Guess you like

Origin www.cnblogs.com/chenxuuu/p/11434016.html