> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/on-premises/zh-cn/pei-zhi/overleaf-toolkit/github-tong-bu.md).

# GitHub 同步

{% hint style="info" %}
此功能由 [ayaka-notes/overleaf-pro](https://github.com/ayaka-notes/overleaf-pro)，由 [yu-i-i/overleaf-cep](https://github.com/yu-i-i/overleaf-cep)。它自 v6.2.0 及更高版本引入。目前仍处于测试阶段。如果你有任何问题，我们需要你的反馈。
{% endhint %}

{% columns %}
{% column %}

<figure><img src="/files/e85b989b6a70f324fdafc13d71bbaceb31621772" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/995fdcf61888149ab6db800955c9a9fc754a17d7" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="/files/4d91788b4fc018d96935bfe21f68cd1991dbfebc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ab3b2b2485dc2c4abcabd323c1ae8fad289361da" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### 设置 GitHub 同步

{% hint style="warning" %}
你需要先启用 [git-bridge](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/git-integration.md) ，然后才能使用 GitHub 同步。

{% code title="config/overleaf.rc" %}

```dotenv
GIT_BRIDGE_ENABLED=true
```

{% endcode %}
{% endhint %}

访问 [开发者设置](https://github.com/settings/developers) 来创建你的 GitHub OAuth 应用，并复制你的 `CLIENT_ID` 和 `SECRET`.&#x20;

**注意**：你的 OAuth 回调 URL 是： `${OVERLEAF_SITE_URL}/user/github-sync/oauth2/callback`.

然后，将以下设置添加到你的 Overleaf 环境变量文件中。

{% code title="config/variables.env" overflow="wrap" %}

```dotenv
# 用于加密用户的 GitHub 访问令牌。
# 生成方法：`openssl rand -hex 32`
GITHUB_TOKEN_CIPHER_PASSWORD=0123456789ABCDEFG # 改成你自己的

# GitHub 同步设置
GITHUB_SYNC_ENABLED=true
GITHUB_SYNC_CLIENT_ID=
GITHUB_SYNC_CLIENT_SECRET=

# OAuth 回调地址是：${OVERLEAF_SITE_URL}/user/github-sync/oauth2/callback
#（可选）GITHUB_SYNC_PROXY_URL=http://10.0.0.1:10808
```

{% endcode %}

{% hint style="warning" %}
在配置 GitHub OAuth 回调 URL 之前，请确保 `OVERLEAF_SITE_URL` 已正确设置。
{% endhint %}

如果你位于中国大陆，可能需要配置代理来访问 GitHub。请设置以下环境变量： `GITHUB_SYNC_PROXY_URL=http://10.0.0.1:10808`.

{% hint style="warning" %}
不要使用 `127.0.0.1` 作为代理主机。如果代理运行在主机服务器上，请使用该服务器的局域网 IP（例如 `192.168.1.xx`）地址，并确保代理已配置为接受来自本地网络设备的连接。
{% endhint %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/on-premises/zh-cn/pei-zhi/overleaf-toolkit/github-tong-bu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
