ignore certain files(types) from git diff

Sometimes it’s silly when reviewing the code change from git diff command which is a simple way to see the differences between the codes from the previous and the updated and the commit contains a large css file. Actually I use less for generating css, so I don’t really need to open up and see the css file. Anyways, you can ignore any file you want from git diff. Here’s how.

You can create a .gitattributes file in the root of the repo. Inside that file, you can now exclude certain files/types from the git diff command just like the way of excluding files from .gitignore:

path/to/file.binary -diff
path/to/files/*.css -diff

Advertisements