{"meta":{"title":"为GitHub Copilot编制存储库索引","intro":"Copilot 通过为存储库编制索引来提高响应。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/zh/enterprise-cloud@latest/copilot/concepts","title":"概念"},{"href":"/zh/enterprise-cloud@latest/copilot/concepts/context","title":"Context"},{"href":"/zh/enterprise-cloud@latest/copilot/concepts/context/repository-indexing","title":"存储库索引编制"}],"documentType":"article"},"body":"# 为GitHub Copilot编制存储库索引\n\nCopilot 通过为存储库编制索引来提高响应。\n\n## 为存储库编制索引的好处\n\nCopilot当存储库的语义代码搜索索引是最新的时，可以优化在存储库上下文中回答自然语言问题和完成任务的能力。\n\n\\*\\*\nCopilot 不会将索引存储库用于模型训练。\\*\\*\n\n## 在Copilot Chat中的语义代码搜索\n\n当你与有存储库上下文的 Copilot Chat 开始对话时，存储库会自动建立索引，以在 GitHub 和 Visual Studio Code 中为你关于代码结构和逻辑的问题提供上下文丰富的答案。 例如，可以询问 **“此存储库如何管理 HTTP 请求和响应？”**， 和 Copilot Chat 会引用你代码的相关部分，提供有依据的答案。\n\n有关如何提问的详细信息，请参阅 [在GitHub中询问有关GitHub Copilot的问题](/zh/enterprise-cloud@latest/copilot/how-tos/copilot-on-github/chat-with-copilot/chat-in-github)。\n\n## 在Copilot cloud agent中的语义代码搜索\n\nCopilot cloud agent 使用语义代码搜索根据含义查找相关代码，而不是只依赖于工具（如 `grep`）的确切文本匹配。 当代理不知道要搜索的精确名称或模式时，语义代码搜索可帮助它更快地找到正确的代码。 无需配置 - 代理在适当时自动使用语义代码搜索。\n\n有关 Copilot cloud agent 的详细信息，请参阅 [关于 GitHub Copilot 云代理](/zh/enterprise-cloud@latest/copilot/concepts/agents/cloud-agent/about-cloud-agent)。\n\n## 关于创建和使用索引\n\n索引编制在后台运行，对于一个大型存储库，初始索引编制可能需要最多 60 秒。 为存储库首次编制索引后，重新编制索引将会更快，并且索引通常会在开始新对话后的数秒内自动更新，以包含最新的更改。\n\n为存储库创建索引后，可以使用它：\n\n* Copilot Chat 和 GitHub 中的 Visual Studio Code\n* Copilot cloud agent\n\n> \\[!TIP] 可以编制索引的存储库数量没有限制。\n\n## 非GitHub 存储库的语义索引\n\nCopilot in Visual Studio Code 可以对托管在外部 GitHub的存储库（如 GitLab 和本地存储库）中的工作区文件使用语义索引。 此功能会将你的数据上传到 GitHub，使其可供搜索。\n\n> \\[!NOTE] 此功能仅在 .GitHub.com 它不可用于 GHE.com 或 GitHub Enterprise Server.\n\n此功能由策略控制，默认情况下处于禁用状态。 对于具有Copilot Business或Copilot Enterprise的组织和企业，企业所有者或组织所有者必须先明确将`Semantic indexing for non-GitHub repositories`策略设为 **“启用”**，成员才能使用该功能。 如果策略保持 **“未配置**”，该功能将保持不可用。 See:\n\n* [管理企业中 GitHub Copilot 的策略和功能](/zh/enterprise-cloud@latest/copilot/how-tos/administer-copilot/manage-for-enterprise/manage-enterprise-policies)\n* [管理组织中GitHub Copilot的策略和功能](/zh/enterprise-cloud@latest/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies)\n\n## 排除答案中的 Copilot Chat 内容\n\n拥有 Copilot Enterprise 或 Copilot Business 计划的企业或组织所有者可定义内容排除项，控制所管理 GitHub Copilot 席位的 Copilot 行为。 有关详细信息，请参阅 [从GitHub Copilot中排除内容](/zh/enterprise-cloud@latest/copilot/how-tos/configure-content-exclusion/exclude-content-from-copilot)。\n\n如果为某个存储库创建语义代码搜索索引，而该存储库属于内容排除策略的一部分，则会根据该策略筛选数据，然后再传递给 Copilot Chat。"}