Patrick Patrick - 8 months ago 34
Git Question

git: re-checkout files after creating smudge filter

Situation: I've just cloned a git repo, and then I configure the smudge filter for the repo. There are

files scattered around the repo that specify the filter that should be used on the files at checkout. But since I setup the filter after the checkout (clone), none of the files were processed.

How can I tell git to go through the repo, find all the
files, and update (re-checkout, apply filter, whatever) all the files which have a smudge filter on them?


Simply re-checkout everything.

cd /path/to/your/repo
git stash save
rm .git/index
git checkout HEAD -- "$(git rev-parse --show-toplevel)"
git stash pop

The smudge filter will be applied at that new checkout.

Note, as seen in this answer, you need to remove the index in order to force the filter to run again.