Skip to content

Instantly share code, notes, and snippets.

@Kirkkt
Last active November 6, 2023 12:36
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kirkkt/b86d453b14f2dab78e09 to your computer and use it in GitHub Desktop.
Save Kirkkt/b86d453b14f2dab78e09 to your computer and use it in GitHub Desktop.
git diff ignoring certain files

git diff ignoring certain files

What is this?

Sometimes you want to ignore certain files when you run git diff, but you still want to check them in, which means you can't capitalize on .gitignore.

This guide is here to help.

How to set it up?

Execute the following once (assuming you are using a mac, otherwise, correct the path to your true):

git config diff.nodiff.command /usr/bin/true

optionally add --global for all repos.

Every time you want to ignore a new file/file regex:

Add a new line to your .git/info/attributes (create one if there ain't one):

{file_regex} diff=nodiff

Example: my .git/info/attributes for web SDK repo

README.md diff=nodiff
TITANIUM_GUIDE.md diff=nodiff
WEB_GUIDE.md diff=nodiff
dist/** diff=nodiff
docs/0_notice.md diff=nodiff
src/titanium/BranchSDK/android/src/io/branch/sdk/BranchSDKModule.java diff=nodiff
src/titanium/BranchSDK/iphone/Classes/IoBranchSdkModule.m diff=nodiff
test/branch-deps.js diff=nodiff
@derrick-branch
Copy link

beautiful. we should add this to the wiki

@mozhata
Copy link

mozhata commented Sep 21, 2018

not work for git version 2.7.4
ubuntu16.04 tls

@ashishnumino
Copy link

This approach is not working for me either on git version git version 2.15.2 (Apple Git-101.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment