git remove all deleted files from entire history
I was wondering if anybody has a more efficient, more intelligent way to do this. The looping construct requires every deleted files to be expunged from every commit by reading each commit. With many commits, this takes a long time.
git log --pretty=format: --name-status | grep -i ^D | cut -f2- | sort -u | xargs -I {} git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch {}' HEAD
That seems to remove each files one at a time.
Consider that git rm
can take multiple files to be removed.
So one optimization would be to build that list and call the filter-branch once.
You can see one example of that approach in "Proper way to remove unwanted files with git filter-branch
without git rm
failing".
上一篇: 当java程序启动时会发生什么?
下一篇: git从整个历史中删除所有已删除的文件