配置 git 以比较 Bun 的 lockb 锁文件
要教会 git 如何针对 Bun 的二进制锁文件格式(.lockb)生成可读的差异,请将以下内容添加到你的本地或全局 .gitattributes 文件中:
gitattributes
*.lockb binary diff=lockb
然后将以下内容添加到你的本地 git 配置中:
terminal
git config diff.lockb.textconv bun
git config diff.lockb.binary true
要为每个仓库配置此功能,请将以下内容添加到你的全局 git 配置中:
terminal
git config --global diff.lockb.textconv bun
git config --global diff.lockb.binary true
工作原理
textconv告诉 git 在进行差异比较前对文件运行 bunbinary告诉 git 将文件视为二进制文件(这样它就不会尝试逐行比较)
在锁文件上运行 Bun(bun ./bun.lockb)会打印出其人类可读的版本,然后由 git diff 对其进行差异比较。