Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude package-lock.json from GitHub contribution activity

Tags:

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.

package-lock.json

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?

like image 375
mythereal Avatar asked May 30 '17 22:05

mythereal


People also ask

Should we ignore package lock json?

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.

Is package lock json needed in github?

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 .

Does package lock json matter?

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.


1 Answers

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 <>' 

enter image description here

FOO_AUTHOR committed with REAL_AUTHOR x time ago.

like image 137
mythereal Avatar answered Sep 22 '22 13:09

mythereal