Reputation: 171
I want to skip some files from git diff. I cannot put them in .gitignore list since i need them and update constantly.
.gitattributes seems to solve this issue for me. But i have no clear idea about how to go about it.
I have tried putting the files after checkin into .gitignore. But it came to my notice that git still considers those files from .gitignore while taking git diff.
I want something like this, but it does not work with my version of git i.e (git version 2.14.1.windows.1)
This question talks about skipping files in git diff by passing the files to skip as parameters to git diff command. But if i do this, i have to keep track of all the files. I want to put the skip list in some kind of .git_______ file which git will implicitly use for skipping while taking git diff
Upvotes: 3
Views: 545
Reputation: 171
We can add all the files to skip in .gitattributes file in the root of git repository
on windows use this command git config diff.nodiff.command C:/"Program\ Files"/Git/usr/bin/true
and on mac use git config diff.nodiff.command usr/bin/true
to set git config.
.gitattributes contents can be as follows:
Readme.md diff=nodiff
xzy.txt diff=nodiff
Then this should skip Readme.md and xyz.txt file changes while taking git diff!
Upvotes: 1