Exclude paths from the Git diff command

This is usefull if you for example have one or more subtrees in your project and you do not want to see changes made in those in your diff

Say you have a folder called ‘common’. This is how to exclude it from git diff:

git diff origin/master -- . ':!/common'

Now if you have a specific file that you want to exclude the command looks like this:

git diff origin/master -- . ':!/rules/form.xml'

And if you want to exclude multiple files of folders:

git diff origin/master -- . ':!/rules/form.xml' ':!/common'

NOTE! ‘origin/master’ is just an example and not part of the solution.

Tested on Git vesion 2.23.0 on Windows 10

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.