import-into
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImport Into
导入到现有清单
Use this skill for .
gh infra import --into=...This workflow is different from normal , , and :
importplanapply- it updates local manifests from live GitHub state
- it may rewrite YAML, local source files, or manifest patches
- it has file-level write modes and skip safety rules
该技能用于命令。
gh infra import --into=...该工作流与常规的、和不同:
importplanapply- 它会根据GitHub实时状态更新本地清单
- 可能会重写YAML、本地源文件或清单补丁
- 具备文件级写入模式和跳过安全规则
When To Use
使用场景
Use this skill when the user wants to:
- pull GitHub state back into existing manifests
- reconcile drift from GitHub UI into local YAML
- decide between ,
write, andpatchskip - understand why a file was skipped during import
- update shared templates safely after repository-side drift
当用户需要执行以下操作时可使用该技能:
- 将GitHub状态拉取回现有清单
- 同步GitHub UI上的变更漂移到本地YAML
- 在、
write和patch模式之间做决策skip - 理解导入过程中文件被跳过的原因
- 仓库侧出现配置漂移后安全更新共享模板
Command
命令
bash
gh infra import <owner/repo> [owner/repo ...] --into=<path><path>bash
gh infra import <owner/repo> [owner/repo ...] --into=<path><path>How It Works
工作原理
- Parse local manifests
- Match target repositories against ,
Repository, andRepositorySetFileSet - Fetch live state from GitHub
- Diff local vs remote
- Show plan output
- For file changes, open the interactive diff viewer
- Write approved local changes
- 解析本地清单
- 将目标仓库与、
Repository和RepositorySet规则匹配FileSet - 从GitHub拉取实时状态
- 对比本地与远程配置的差异
- 输出执行计划
- 针对文件变更,打开交互式差异查看器
- 写入审批通过的本地变更
File Write Modes
文件写入模式
- : update the normal local target
write - : store the drift under
patchpatches: - : ignore for this run
skip
Typical defaults:
- inline content:
write - single-use local source:
write - shared local source:
patch - existing entry:
patches:patch - many entries:
create_onlyskip
- :更新常规本地目标文件
write - :将漂移配置存储在
patch字段下patches: - :本次运行忽略该变更
skip
典型默认规则:
- 内联内容:
write - 单次使用的本地源:
write - 共享本地源:
patch - 已有条目:
patches:patch - 大量条目:
create_onlyskip
Safety Rules
安全规则
There are two skip modes:
- default skip: safe enough to import, but skipped by default
- hard skip: cannot be written back safely
Hard-skip cases include:
- sources
github:// - template-backed files whose placeholders cannot be reverse-mapped safely
存在两种跳过模式:
- 默认跳过:足够安全可以导入,但默认被跳过
- 强制跳过:无法安全回写
强制跳过的场景包括:
- 源文件
github:// - 占位符无法安全反向映射的模板支撑文件
Template-Backed Files
模板支撑文件
For templates such as and , gh-infra compares:
<% .Repo.Name %><% .Repo.FullName %>- rendered local template
- remote GitHub file
It then tries to reconstruct updated local template source while preserving placeholders.
Use only when you want to update the underlying shared source. Use when drift should stay repository-specific.
writepatch对于包含和这类变量的模板,gh-infra会对比:
<% .Repo.Name %><% .Repo.FullName %>- 渲染后的本地模板
- 远程GitHub文件
随后会尝试重建更新后的本地模板源,同时保留占位符。
仅当你需要更新底层共享源时使用模式;当漂移配置需要保留为仓库专属配置时使用模式。
writepatchWhat Gets Updated
可更新内容
- repository settings: patched into YAML
- inline file content: written back into the manifest
- local files: written back to the source file
source: ./... - shared local source files: often better stored as patches
- 仓库设置:作为补丁写入YAML
- 内联文件内容:回写到清单中
- 本地文件:回写到源文件
source: ./... - 共享本地源文件:通常更适合存储为补丁
What Does Not Get Imported
无法导入内容
- secrets: GitHub does not return secret values
- sources: no local write target
github:// - template-backed files that cannot be reverse-mapped safely
- 密钥:GitHub不会返回密钥值
- 源文件:无本地写入目标
github:// - 无法安全反向映射的模板支撑文件
Read Next
后续阅读
- Examples and detailed behavior: references/behavior.md
- Diff-viewer decisions: references/write-modes.md
- Template safety: references/template-safety.md
- 示例与详细行为:references/behavior.md
- 差异查看器决策规则:references/write-modes.md
- 模板安全:references/template-safety.md