Git : ignore package-lock.json or yarn.lock in diff

26 Jun 2018

Git diff with package-lock.json/yarn.lock is difficult since you need to scoll though too much noice, but we can’t git ignore those as well. Those files are suppose to be checked into the repository.

git diff

But those can be easily ignored only from the diff.

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

You can add this to your default alias for git diff.

alias gd="git diff -- ':!package-lock.json' ':!yarn.lock'"

Hope this tip helped.
Comments are welcome.

Versions of Language/packages used in this post.

| Library/Language  | Version |
| ----------------- |---------|
|      Git          |  2.17.1 |
If you particularly enjoy my work, I appreciate donations via PayPal.
comments powered by Disqus