Removing Exif Data From Images in Git
In WSL, strip everything:
Then, install BFG, and run it to remove all of the images from our previous commits (except the most recent one, where we’ve stripped everything of EXIF information).
Then follow the rest of the instructions on the BFG webpage:
Guarding The Future
All we need to do is create an executable
pre-commit file, which can be created by copying the existing
pre-commit.sample file within
.git/hooks. See here for more details.
pre-commit file seems to execute in a self-contained copy of Bash, per this SO answer, which means we can use our favorite Unix utilities. Following the guidance from here, my
pre-commit file just finds the changed files, and passes them to the
strip_exif.py python script. Here’s the most basic version - there’s more to be found in the actual
Note that the script seems to always execute from the root of the git repo, which means we can hard-code paths to our python scripts and such. On my Windows install, it seems to be executing
C:\Program Files\Python310\python.exe, which I’d guess is based on the system
PATH. Presumably, the same would be true on Linux.
Also - TIL that the
.git folder isn’t actually committed to the repo! This means all of your git hooks are local. I’ve moved the
strip_exif.py script and the
pre-commit script into the actual Git repo (strip_exif and pre-commit), and then added a symlink from inside the
.git/hooks folder with
ln -s ../../content/posts/static/pre-commit ..