Now that npm v5.0.0 is out, using npm packages auto-generates a package-lock.json
on npm install
. In my case, my package-lock.json
file happens to be close to 10,000 lines of code.
Npm also suggests this file should be committed:
npm notice created a lockfile as package-lock.json. You should commit this file.
I don't want this file to be included in the line counts for the contribution activity on GitHub.
I've tried setting the files as vendored code in .gitattributes
, but that only affects the repository language.
Is there a way to exclude a file from the contribution activity without adding it to .gitignore
?
If you're collaborating on a shared project with multiple developers, and you want to ensures that installations remain identical for all developers and environments, you need to use package-lock. json . package-lock. json is automatically generated for any operations where npm modifies either package.
The package-lock. json file needs to be committed to your Git repository, so it can be fetched by other people, if the project is public or you have collaborators, or if you use Git as a source for deployments. The dependencies versions will be updated in the package-lock. json file when you run npm update .
The goal of package-lock. json file is to keep track of the exact version of every package that is installed so that a product is 100% reproducible in the same way even if packages are updated by their maintainers. This solves a very specific problem that package. json left unsolved.
One way to exclude a file from modifying a user's contribution activity is by associating the commit with a placeholder author. This can be done by providing an empty email field <>
in the --author
option.
The signature of the --author
option: --author="NAME <EMAIL>"
git add package-lock.json git commit -m 'initial commit' --author='nocontribute <>'
FOO_AUTHOR committed with REAL_AUTHOR x time ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With