跳到主内容
版本:9.x

Git Branch Lockfiles

Git branch lockfiles 允许您完全避免 lockfile 合并冲突并稍后解决。

使用 git branch lockfiles

You can turn on this feature by configuring the .npmrc file.

git-branch-lockfile=true

通过这样做,lockfile 文件的名称将根据当前 git 分支名称生成。

For instance, the current branch name is feature-1. Then, the generated lockfile name will be pnpm-lock.feature-1.yaml. 您可以将其提交到 Git,并稍后合并所有 git branch lockfiles 文件。

- <project_folder>
|- pnpm-lock.yaml
|- pnpm-lock.feature-1.yaml
|- pnpm-lock.<branch_name>.yaml
注意

feature/1 is special in that the / is automatically converted to !, so the corresponding lockfile name would be pnpm-lock.feature!1.yaml.

合并 git branch lockfiles

pnpm install --merge-git-branch-lockfiles

To merge all git branch lockfiles, just specify --merge-git-branch-lockfiles to pnpm install command.

After that, all git branch lockfiles will be merged into one pnpm-lock.yaml

分支匹配

pnpm allows you to specify --merge-git-branch-lockfiles by matching the current branch name.

For instance, by the following setting in .npmrc file, pnpm install will merge all git branch lockfiles when running in the main branch and the branch name starts with release.

merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*