shopify theme pull 后本地文件和线上不一致
现象#
执行 shopify theme pull 后打开本地 templates/index.json,里面还是上周的区块,而编辑器里明明已经改过。
原因#
- pull 默认拉取最近使用的主题或开发主题,并非已发布主题
- 本地存在未提交修改时 pull 会覆盖同名文件,看起来像拉到了旧内容
- 编辑器保存会把设置写进模板 JSON,指定了错误的主题 id 就会拿到另一份数据
.shopifyignore排除了某些目录,pull 时被整体跳过
处理步骤#
- 先执行
shopify theme list,记下已发布主题的 id 与名称 - 用
shopify theme pull --live --path ./theme明确拉取线上版本 - pull 前先
git status,有本地改动就git stash保护 - 检查根目录
.shopifyignore是否排除了 templates 或 sections - 拉完用
git diff逐条确认,只提交线上真实发生的变更
验收标准#
本地 templates/index.json 的 section 列表与编辑器侧栏一致,diff 中没有意外删除。
本文由 风格技术 技术团队整理,适用于 Shopify 标准版与 Plus 店铺。Shopify 平台能力迭代较快,具体操作路径与字段以官方文档和店铺后台实际版本为准。