> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/docs-as-code/git-sync/commits.md).

# 提交信息与自动链接

默认情况下，当将内容从 GitBook 导出到 Git 仓库时，GitBook 会根据已合并的更改请求生成提交消息：

```
GITBOOK-14：改进关于用户管理的文档
```

## 自动链接 `GITBOOK-<num>` 在 GitHub 和 GitLab 中

如果你想自动将提交中的 GitBook 变更请求 ID（例如 *GITBOOK-123*）转换为链接，可以通过 GitHub 的 *自动链接引用* 功能启用此功能。请参阅 [GitHub](https://help.github.com/en/github/administering-a-repository/configuring-autolinks-to-reference-external-resources).

使用以下 URL 格式，其中 `spaceId` 对应于你的分区 URL：

`<https://app.gitbook.com/s/{spaceId}/~/changes/<num>/>`

<div data-full-width="false"><figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-b4b65fa8a67b33cf55b44b4749804171e954c7d4%2F25_12_10_gitsync_autolink%402x.png?alt=media" alt="A GitBook screenshot showing autolink setup"><figcaption><p>自动链接设置。</p></figcaption></figure></div>

## 自定义提交消息模板

使用 GitBook 时，如果采用 [单体仓库](https://gitbook.com/docs/documentation/zh/docs-as-code/git-sync/monorepos.md)，或者你对提交消息有特定规范，可能会希望自定义 GitBook 向 Git 推送提交时使用的消息。

模板可以包含以下占位符：

* `{change_request_number}` 变更请求的唯一数字 ID
* `{change_request_subject}` 合并时变更请求的主题；如果未提供， `No subject` 则为默认值。

默认模板为：

```
GITBOOK-{change_request_number}: {change_request_subject}
```

## 大型导出

当 GitBook 将大型更新导出到 GitHub 或 GitLab 时，会将导出内容拆分为多个提交，每个提交最大为 500 MiB，而不是推送单个提交。同步需要更长时间才能完成，并且仓库中会针对一次 GitBook 更新显示多个提交。

GitBook 会先尝试将这些提交直接推送到已同步的分支。如果导出开始后分支发生了变化，或者分支保护规则拒绝了推送，GitBook 就会创建拉取请求（GitHub）或合并请求（GitLab），并尝试自动合并。如果仓库设置阻止了合并，拉取请求或合并请求会保持打开状态，供你审核并合并。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/docs-as-code/git-sync/commits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
