Skip to main content
Version: 9.x

使用 Git

锁文件

¥Lockfiles

你应该始终提交锁定文件 (pnpm-lock.yaml)。造成这种情况的原因有很多,其中最主要的是:

¥You should always commit the lockfile (pnpm-lock.yaml). This is for a multitude of reasons, the primary of which being:

  • 由于能够跳过包解析,它可以更快地安装 CI 和生产环境

    ¥it enables faster installation for CI and production environments, due to being able to skip package resolution

  • 它在开发、测试和生产环境之间强制执行一致的安装和解决方案,这意味着测试和生产中使用的包将与开发项目时完全相同

    ¥it enforces consistent installations and resolution between development, testing, and production environments, meaning the packages used in testing and production will be exactly the same as when you developed your project

合并冲突

¥Merge conflicts

pnpm 可以自动解决 pnpm-lock.yaml 中的合并冲突。如果有冲突,只需运行 pnpm install 并提交更改。

¥pnpm can automatically resolve merge conflicts in pnpm-lock.yaml. If you have conflicts, just run pnpm install and commit the changes.

但请注意。建议你在提交提交之前检查更改,因为我们不能保证 pnpm 会选择正确的头 - 相反,它使用最新的锁定文件构建,这在大多数情况下都是理想的。

¥Be warned, however. It is advised that you review the changes prior to staging a commit, because we cannot guarantee that pnpm will choose the correct head - it instead builds with the most updated of lockfiles, which is ideal in most cases.