> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gitea 同步

> 連結您的 Gitea 帳號、匯入或匯出專案、雙向同步變更，以及解除連結。

將專案連接至 Gitea 儲存庫。變更會雙向同步，而且只會在您點選 **Sync** 時進行：不會自動同步任何內容。

> [!NOTE]
>
> 管理員必須先啟用 [Gitea 同步](https://ayakaleaf-pro.mintlify.site/zh-TW/on-premises/configuration/overleaf-toolkit/integrations/gitea-synchronisation.md)。

## 連結您的 Gitea 帳號

這只需要做一次。

**1. 開啟帳號設定**

點選 **Account**，然後點選 **Account settings**。在 **Project synchronisation** 下找到 **Gitea**，點選 **Link**。

![帳號設定中的 Gitea 區段，含有 Link 按鈕](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-link.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=5514bcd66b524c3dde2376db09935feb)

帳號設定中的 Gitea

**2. 在 Gitea 上授權**

Gitea 會開啟。如有要求請登入，然後授權該應用程式。

**3. 檢查連結**

您會回到帳號設定。一則綠色訊息表示您的 Gitea 帳號已連結，按鈕現在顯示為 **Unlink**。

![帳號設定中的 Gitea 區段，含有 Unlink 按鈕](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-linked.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=b0eb94a11ff546a6770d4f5a8b5250de)

您的 Gitea 帳號已連結

如果您的帳號尚未連結，**Import from Gitea** 與編輯器中的 **Gitea** 卡片會先要求您連結帳號。點選 **Link to your Gitea account**。您同樣會進入帳號設定，如果是從編輯器開始，則會在新分頁中開啟。然後返回並重新開始。

![含有 Link to your Gitea account 按鈕的 Import from Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-link-prompt.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=b9f6e8fc7d3aa2d3328423f660de5a9c)

帳號未連結時的提示

## 匯入儲存庫

這會從 Gitea 儲存庫建立新專案，並且已與該儲存庫連結。

**1. 開啟匯入對話方塊**

在專案頁面中，點選 **New project**，然後點選 **Import from Gitea**。

![含有 Import from Gitea 的 New project 選單](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-new-project-menu.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=de3258081da7ec5af1083ae6c127d510)

New project 選單

**2. 選擇儲存庫**

點選儲存庫旁的 **Import to Overleaf**。清單包含您的儲存庫以及您所屬組織的儲存庫。空的儲存庫不會列出：它至少需要一個提交。

![列出四個儲存庫的 Import from Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-import.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=9b8c86ed6705efddab590e0e8f62892c)

您的 Gitea 儲存庫

**3. 檢查專案**

新專案會開啟，並包含儲存庫中的檔案。

![編輯器顯示匯入的專案及其檔案與編譯後的 PDF](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-imported.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=bd72f7c7594e0f80e0966d4691598db3)

匯入的專案

## 將專案匯出至新的儲存庫

這會從專案建立儲存庫，並將兩者連結。專案只能透過這種方式或匯入來連結：您無法將它連結至已存在的儲存庫。

**1. 在編輯器中開啟 Gitea**

開啟專案。在左側欄中點選 **Integrations**，然後點選 **Gitea**。

![含有 Gitea 卡片的 Integrations 面板](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-integrations.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=12710e50eecf8f3b385565c85b4a45a4)

Integrations 面板

**2. 填寫儲存庫資訊**

選擇 **Owner**，可以是您自己，也可以是您所屬的某個組織。選擇組織時，此欄位名稱為 **Organization**。**Repository Name** 預設為專案名稱：如果名稱中有空格，請加以變更，因為 Gitea 不接受空格。描述為選填，**Private** 預設為已選取。點選 **Create a Gitea repository**。

![已填寫的 Export Project to Gitea 表單](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-export.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=867cf2d205d151a87dd35529b4e40d56)

Export Project to Gitea

如果名稱中有空格或已被使用，對話方塊會顯示 **Please check that the repository name is valid, and that you have permission to create the repository.** 請變更名稱，然後再次點選按鈕。

**3. 檢查連結**

對話方塊現在顯示 **This project is linked to** 以及儲存庫名稱。

![匯出後的 Sync with Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-exported.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=aa8d526d60f9733ba1885e73621ab8d6)

專案已連結

## 同步

**1. 開啟同步對話方塊**

開啟已連結的專案。在左側欄中點選 **Integrations**，然後點選 **Gitea**。

**Recent commits in Gitea** 會列出即將進入專案的內容。

![列出一個新提交的 Sync with Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-new-commits.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=0403560179cb63a6b5d3853f4590e6a5)

Gitea 中有一個新提交在等待

**2. 描述您的變更**

如果您在專案中做了變更，會出現提交訊息欄位。此欄位為選填：如果留空，提交名稱為 `Updates from Overleaf`。

![已填寫提交訊息的 Sync with Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-commit-message.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=014cd300d4deff341310920221c63a30)

您的變更的提交訊息

**3. 點選 Sync**

點選 **Sync**。來自 Gitea 的新提交會進入專案，您的變更會推送至儲存庫的預設分支。如果兩邊修改了不同的內容，系統會透過一個拉取請求為您合併，該拉取請求會作為紀錄保留在 Gitea 上。

**4. 檢查結果**

對話方塊顯示 **No new commits in Gitea since last merge.**，提交訊息欄位也消失了。編輯器中的檔案與 Gitea 上的提交都已是最新狀態。

![同步後沒有新提交的 Sync with Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-done.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=7a53483772e17e5ad75d5ceb7f44e34e)

一切皆已同步

### 如果兩邊修改了相同的行

對話方塊會提示無法合併變更，並指出一個新分支 `overleaf-YYYY-MM-DD-HHMMSS`，其中保存了您的變更。Overleaf 也會在 Gitea 上從該分支開啟一個拉取請求。

![含有合併衝突警告的 Sync with Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-conflict.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=9acaf32d0930decd2cfce516037a37b1)

衝突

1. 使用 Git 將該分支合併至預設分支，並修正衝突。在此期間您可以關閉對話方塊：再次開啟時會顯示相同的訊息。

   ```bash theme={null}
   git clone <repository-address>
   cd <repository-name>
   git merge origin/overleaf-YYYY-MM-DD-HHMMSS
   # fix the conflict in the file Git names
   git add <file>
   git commit
   git push
   ```
2. 點選 **I have manually merged. Continue**。合併後的結果會進入專案。如果在分支合併之前點選，對話方塊會維持不變。
3. 該分支會保留在 Gitea 上，其拉取請求也會維持開啟。不再需要時，請關閉拉取請求並刪除分支。

當分支保護規則擋下拉取請求時（例如需要核准），即使沒有衝突的行，也會出現相同的對話方塊。一旦規則允許，請在 Gitea 上合併該拉取請求，然後點選 **I have manually merged. Continue**。請參閱[與 Gitea 同步的運作方式](https://ayakaleaf-pro.mintlify.site/zh-TW/on-premises/configuration/overleaf-toolkit/integrations/gitea-synchronisation.md#how-syncing-works-with-gitea)。

## 解除專案連結

當您不再希望專案同步時執行此操作。

**1. 點選 Unlink**

在同步對話方塊中，點選 **Unlink**。

**2. 確認**

點選 **Confirm**。這只會移除連結：警告中提到的連接至您擁有的儲存庫，是您之後可以選擇的操作，而不是現在就會發生的事。

![要求確認解除連結的 Sync with Gitea 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-unlink-project.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=796d5581463a481fed1772d6695430d1)

確認解除連結

**3. 檢查結果**

對話方塊現在顯示 **Export Project to Gitea**。專案與儲存庫都會保留各自的內容。若要再次同步，請將專案匯出至新的儲存庫，或將儲存庫匯入為新專案。

## 解除您的 Gitea 帳號連結

在 **Account settings** 的 **Gitea** 下，點選 **Unlink**，然後在對話方塊中再次點選 **Unlink**。

![Unlink Gitea Account 對話方塊](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/gitea-sync-unlink-account.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=b3995614c688a587c031de666d71ce64)

解除您的帳號連結

您的專案仍與各自的儲存庫保持連結。在您再次連結帳號之前，無法同步它們。

> [!NOTE]
>
> 關於共用專案中誰可以做什麼，請參閱[誰可以連結與同步](https://ayakaleaf-pro.mintlify.site/zh-TW/on-premises/configuration/overleaf-toolkit/integrations/gitea-synchronisation.md#who-can-link-and-sync)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.