Git Branch Lockfiles
Git 分支锁文件允许你完全避免锁文件合并冲突并稍后解决。
使用 Git 分支锁文件#
你可以通过配置 pnpm-workspace.yaml 文件来打开此功能。
gitBranchLockfile: true
通过这样做,锁文件的名称将根据当前 Git 分支名称生成。
例如,当前分支名称是 feature-1。那么,生成的锁文件名称就会是 pnpm-lock.feature-1.yaml。你可以将其提交到 Git,并稍后合并所有 Git 分支锁文件。
- <project_folder>
|- pnpm-lock.yaml
|- pnpm-lock.feature-1.yaml
|- pnpm-lock.<branch_name>.yaml
注意
Every character in the branch name other than ASCII letters, digits, _, ., and - is converted to !,
and the name is lowercased. So the lockfile of the Feature/1 branch is pnpm-lock.feature!1.yaml.
A character outside the Basic Multilingual Plane, such as an emoji, becomes !!.
合并 Git 分支锁文件#
pnpm install --merge-git-branch-lockfiles#
要合并所有 Git 分支锁文件,只需指定 --merge-git-branch-lockfiles 到 pnpm install 命令。
After that, all git branch lockfiles will be merged into one pnpm-lock.yaml, and the branch lockfiles are deleted.
Branch matching#
pnpm 允许你通过匹配当前分支名称指定 --merge-git-branch-lockfiles 。
For instance, by the following setting in pnpm-workspace.yaml file, pnpm install will merge all git branch lockfiles when
running in the main branch or in a branch whose name starts with release.
mergeGitBranchLockfilesBranchPattern:
- main
- release*
See gitBranchLockfile and mergeGitBranchLockfilesBranchPattern for the setting reference.