Skip to content

Instantly share code, notes, and snippets.

@kendallroth
Created January 24, 2022 17:43
Show Gist options
  • Save kendallroth/407595690c5edcaab6dee211b08386c8 to your computer and use it in GitHub Desktop.
Save kendallroth/407595690c5edcaab6dee211b08386c8 to your computer and use it in GitHub Desktop.
Exclude files from Gid diff

Some projects may have files that should be skipped in Git diff but still show in Git status (and be tracked). This can be made possible with a custom diff driver that uses a no-op command.

Adapted from StackOverflow - @KurzedMetal.

Custom diff driver

Create a global no-op diff command driver with the following command. Note that driver can be limited to local respository by removing the --global flag.

git config diff.nodiff.command /bin/true

Apply diff driver

Assign the new diff driver to files that should be ignored in the repository .git/info/attributes file.

*.asset diff=nodiff

# Example with other attributes
*.asset diff=nodiff merge=unityyamlmerge eol=lf

A committed .gitattributes file may be used to share modified attributes with other developers; however, they will also need a custom nodiff driver!

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