> 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-tw/she-ding/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 及之後版本引入。目前仍處於 beta 狀態。如果您有任何問題，請提供意見回饋。
{% endhint %}

{% columns %}
{% column %}

<figure><img src="/files/61d096733d12fafe5d3a3c06acbe03f26d4e439a" alt=""><figcaption></figcaption></figure>

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

{% column %}

<figure><img src="/files/12c6ba9a1f3b05c68ae70fa13dbcd7086a0560a3" alt=""><figcaption></figcaption></figure>

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

### 設定 GitHub 同步

{% hint style="warning" %}
您需要先啟用 [git-bridge](/on-premises/zh-tw/she-ding/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 回呼網址為： `${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 回呼網址之前，請先確認 `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-tw/she-ding/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.
