> 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/ja-gitbook-documentation/getting-started/git-sync/enabling-gitlab-sync.md).

# GitLab Sync を有効にする

### はじめに

GitLab リポジトリと同期したいセクションで、 **設定する** の横の **Git Sync** の [セクション見出し](/docs/documentation/ja-gitbook-documentation/rissu/gitbook-ui.md#space-header)をクリックします。プロバイダー一覧で、 **GitLab Sync**、クリックして **設定する**.

<figure><img src="/files/80603c3dc406f70f3af0ef4089c9a925bfa65b6f" alt="A GitBook screenshot showing GitLab Sync configuration options"><figcaption><p>GitLab Sync の設定オプション。</p></figcaption></figure>

### API アクセストークンを生成して入力します

GitLab のユーザー設定で API アクセストークンを生成できます。

{% hint style="info" %}
GitLab には 2 種類のアクセストークンがあります: Project と Personal です。連携を機能させるには Personal トークンを使用する必要があることに注意してください。これは GitLab のユーザー設定メニューから生成できます。
{% endhint %}

トークンで次のアクセス権を有効にしてください:

* `api`
* `read_repository`
* `write_repository`

作成したトークンに特定のロールが付与されている場合は、それが `メンテナー` または `管理者` ロールであることも確認してください。

その後、GitLab 連携を設定するときに、そのトークンを API アクセストークン欄に貼り付けます。

### リポジトリとブランチを選択する

GitBook コンテンツと同期を維持したいリポジトリを選択します。

{% hint style="info" %}
**リポジトリが見つかりませんか？** API トークンを作成するときは、正しい権限を設定していることを確認してください。
{% endhint %}

正しいリポジトリを選択したら、コミットをどのブランチにプッシュし、そこから同期するかを選びます。

{% hint style="warning" %}
多くの GitLab リポジトリでは、 `main ブランチ` ブランチが自動的に保護対象に設定される場合があります。その場合は、コンテンツを同期するための特定のブランチを追加することをおすすめします。その後、これを `main ブランチ` にマージして、保護はそのまま維持します。
{% endhint %}

### 初回同期を実行する

初めて同期する際は、次の 2 つの方向のいずれかで同期できます:

1. GitBook -> GitLab では、セクションのコンテンツを同期します **へ** 選択したブランチへ。空のリポジトリから始めて、GitBook コンテンツをすばやく取り込みたい場合に最適です。
2. GitLab -> GitBook では、セクションのコンテンツを同期します **から** 選択したブランチから。リポジトリに既存の Markdown コンテンツがあり、それを GitBook に取り込みたい場合に最適です。

### 書き込みとコミット

これで準備完了です。セクションが [ライブ編集](/docs/documentation/ja-gitbook-documentation/collaboration/live-edits.md) モードでは、ライブ編集は現在ロックされています。これにより、チームの誰かが a をマージしたときに、GitBook がリポジトリへコンテンツを確実に同期できるようになります。 [変更リクエスト](/docs/documentation/ja-gitbook-documentation/collaboration/change-requests.md) をマージしたときに、リポジトリへ確実にコンテンツを同期できます。

GitBook で編集すると、変更リクエストのマージごとに、選択した GitLab ブランチへのコミットが作成されます。

GitLab にコミットすると、すべてのコミットが履歴コミットとして GitBook のセクションに同期されます。


---

# 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://gitbook.com/docs/documentation/ja-gitbook-documentation/getting-started/git-sync/enabling-gitlab-sync.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.
