Dev/Git

Git remove files completely from whole history

brainscaling 2019. 12. 2. 15:10

Clone repository with mirror option

git clone "remote/path" 

Use filter_branch to remove files

git filter-branch --force --tree-filter 'rm -f path/to/files.png' HEAD

Use filter_branch to remove directory

git filter-branch --force --tree-filter 'rm -rf path/to/directory' HEAD

Purge the unwanted data

git reflog expire --expire=now --all && git gc --prune=now --aggressive

Force push to the repository

git push --force