Answers for "git remove a file from commit history"

3

how to remove git history for a file

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file" HEAD
Posted by: Guest on April-01-2021
0

git remove files from old commits

git filter-branch --index-filter 
'git rm --cached --ignore-unmatch path/to/mylarge_file' 
--tag-name-filter cat -- --all

filter-branch keeps backups too, so the size of the repo won't decrease immediately unless you expire the reflogs and garbage collect:

rm -Rf .git/refs/original       # careful
git gc --aggressive --prune=now # danger
Posted by: Guest on March-07-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language