简体   繁体   English

从GitHub贡献活动中排除package-lock.json

[英]Exclude package-lock.json from GitHub contribution activity

Now that npm v5.0.0 is out, using npm packages auto-generates a package-lock.json on npm install . 现在npm v5.0.0已经用完了,使用npm包package-lock.jsonnpm install上自动生成一个package-lock.json In my case, my package-lock.json file happens to be close to 10,000 lines of code. 就我而言,我的package-lock.json文件恰好接近10,000行代码。

包lock.json

Npm also suggests this file should be committed: Npm还建议提交此文件:

npm notice created a lockfile as package-lock.json. npm notice创建了一个lockfile作为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. 我不希望此文件包含在GitHub上的贡献活动的行数中。

I've tried setting the files as vendored code in .gitattributes , but that only affects the repository language . 我已经尝试设置文件为vendored代码.gitattributes ,但只影响库的语言

Is there a way to exclude a file from the contribution activity without adding it to .gitignore ? 有没有办法从贡献活动中排除文件而不将其添加到.gitignore

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. 这可以通过在--author选项中提供空的电子邮件字段<>来完成。

The signature of the --author option: --author="NAME <EMAIL>" --author选项的签名: - --author="NAME <EMAIL>"

git add package-lock.json
git commit -m 'initial commit' --author='nocontribute <>'

在此输入图像描述

FOO_AUTHOR committed with REAL_AUTHOR x time ago. FOO_AUTHOR使用REAL_AUTHOR x时间前提交。

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. 省略--global仅在此存储库中设置标识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM