如何将 project.lock.json 文件添加到 gitignore

How to add project.lock.json file to gitignore

我正在尝试如下操作:

#DNX
project.lock.json

*.lock.json

但它似乎并没有忽略这些文件。

如果文件已经被跟踪到git,那么你必须先删除它(物理上文件必须暂时放在git文件夹之外),提交更改并再次添加文件到文件夹。然后 git 将开始使用您的指令忽略它。

来自 https://docs.microsoft.com/en-us/nuget/schema/project-json :

The project.lock.json file is generated in the process of restoring the NuGet packages in projects that use project.json. It holds a snapshot of all the information that is generated as NuGet walks the graph of packages and includes the version, contents, and dependencies of all the packages in your project. The build system uses this to choose packages from a global location that are relevant when building the project instead of depending on a local packages folder in the project itself. This results in faster build performance because it's necessary to read only project.lock.json instead of many separate .nuspec files.

The project.lock.json is automatically generated on package restore, so it can be omitted from source control by adding it to .gitignore and .tfignore files. However, if you include it in source control, the change history will show changes in dependencies resolved over time.