最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Exclude package-lock.json from GitHub contribution activity - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question edited May 31, 2017 at 7:59 mythereal asked May 30, 2017 at 22:35 mytherealmythereal 8031 gold badge10 silver badges23 bronze badges 4
  • 2 Maybe try marking the file as binary in .gitattributes. I don't know if Github will respect that. – user1726343 Commented Jun 23, 2017 at 17:55
  • 3 I asked GitHub support and at the time of writing this, there is no support for this sort of functionality – allejo Commented Jul 17, 2017 at 8: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 Commented Aug 3, 2017 at 5:53
  • 1 @AsadSaeeduddin I had the same idea, just tried it out, no it won't :( – depoulo Commented Oct 20, 2017 at 9:07
Add a comment  | 

2 Answers 2

Reset to default 15

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.

Run

git config --global user.email "[email protected]"

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

to set your account's default identity.

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

发布评论

评论列表(0)

  1. 暂无评论