29

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?

mythereal
  • 773
  • 9
  • 22
  • 1
    Maybe try marking the file as `binary` in `.gitattributes`. I don't know if Github will respect that. – Asad Saeeduddin Jun 23 '17 at 17:55
  • 2
    I asked GitHub support and at the time of writing this, there is no support for this sort of functionality – allejo Jul 17 '17 at 08:41
  • been a bit, but this has been annoying me too, if, you have no care to use it's time travelling magic, can you just delete it from time to time, tell node not to make it? – edencorbin Aug 03 '17 at 05:53
  • 1
    @AsadSaeeduddin I had the same idea, just tried it out, no it won't :( – depoulo Oct 20 '17 at 09:07

2 Answers2

14

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.

mythereal
  • 773
  • 9
  • 22
-4

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

to set your account's default identity.

Omit --global to set the identity only in this repository.

FrankS101
  • 2,112
  • 6
  • 26
  • 40