Show images on git diff
Today I learned how to show binary files, more specifically images, using git diff
or git show
CLI. For that I am using iTerm2 imgcat.
In order to get there I had to configure git to allow a custom diff command to specific file types.
So I used git attributes to do that:
echo "*.gif diff=image" >> ~/.gitattributes
echo "*.jpg diff=image" >> ~/.gitattributes
echo "*.png diff=image" >> ~/.gitattributes
git config --global core.attributesfile '~/.gitattributes'
Then I had to change the git diff text converter to use iterm2 imgcat:
git config --global diff.image.textconv 'imgcat'
Check this out:
Notes:
-
imgcat
does not work with new versions of tmux -
git pagers like
less
ormore
won't work either, so you can rungit --no-pager diff
or you can pipe with cat like:
git diff | cat
Check also Open images in vim
Tweet