3

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

Ashish Gaude
  • 161
  • 6
  • Possible duplicate of [Want to exclude file from “git diff”](https://stackoverflow.com/questions/10415100/want-to-exclude-file-from-git-diff) – Romain Valeri Oct 03 '18 at 09:40
  • @RomainVALERI Not exactly! I want to keep the list of all the files to be skipped while taking git-diff in a separate file like .gitattributes This removes my headache of keeping track of which files am i skipping while taking git diff as mentioned in above link where he is passing the list of files to skip as parameters – Ashish Gaude Oct 03 '18 at 09:45
  • That "something like this" you linked has been in Git since long before 2.14. – jthill Oct 03 '18 at 10:05
  • @jthill yes! could figure that out. Thanks – Ashish Gaude Oct 03 '18 at 12:40

1 Answers1

1

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!

Ashish Gaude
  • 161
  • 6