Amit Dhamu

Writes Code

Hide Minified File Contents From Git History

Compiled JavaScript and CSS files can litter git diffs and logs and make it hard to determine what exactly has changed. Instead, developers should refer to the source files for changes rather than the compiled ones.

In order to do this, add the following to your .gitattributes file.

# <file> -diff
styles.min.css -diff
script.min.js -diff

This essentially marks the said files as binary and a git diff will simply state they differ rather than showing any code changes.


git / diff / gitattributes

← Search Occurrences In Between Two Strings Install Ruby Gem Behind Proxy →