Search code examples
gitpackage-lock.json

No effect when doing git diff -- ':(exclude)package-lock.json'


I want to a do a diff but without package-lock.json which is huge and is a generated file so nothing interesting for me there. I tried both :

git diff -- ':(exclude)package-lock.json'

git diff -- ':!package-lock.json'

but it has just zero output. What am I doing wrong ? I am running git 2.21.0


Solution

  • Before using exclude pathspec you need to list non-exclude paths. Dot, for example, or a magic root :/:

    git diff -- . ':(exclude)package-lock.json'
    git diff -- . ':!package-lock.json'