> 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/docs-as-code/git-sync/monorepos.md).

# モノレポ

モノレポで Git Sync を使用し、スペースを別々のディレクトリにマッピングします

サイト全体の Git Sync を使用して、1 つのリポジトリとブランチから複数のスペースを同期します。各スペースをそれぞれのディレクトリにマッピングします `gitbook-docs.yaml`.

### サイト全体の Git Sync の仕組み

サイトの **プロジェクトディレクトリ** Git Sync のインストールディレクトリを設定します。 `gitbook-docs.yaml` そこにあります。空のままにすると、GitBook はリポジトリのルートを使用します。

では `gitbook-docs.yaml`、各スペースには `content.directory`ディレクトリがあります。そのディレクトリにはスペースの `.gitbook.yaml`, `README.md`, `SUMMARY.md`、およびコンテンツファイルが含まれます。

これらのファイルの概要については、次を参照してください [コンテンツの設定](/docs/documentation/ja-gitbook-documentation/docs-as-code/git-sync/content-configuration.md).

### スペースをディレクトリにマッピングする

使用 **コンテンツのマッピング** Git Sync パネルで各スペースをマッピングします。GitBook はそのマッピングを `gitbook-docs.yaml`.

ディレクトリパスは次のように機能します：

| パス       | 意味                           |
| -------- | ---------------------------- |
| `./docs` | サイトの Project ディレクトリ内のディレクトリ。 |
| `/docs`  | リポジトリのルートからのディレクトリ。          |
| `docs`   | と同じ `./docs`.                |

たとえば、このリポジトリは 3 つのスペースをマッピングします：

```
/
  gitbook-docs.yaml
  documentation/
    .gitbook.yaml
    README.md
    SUMMARY.md
    .gitbook/
      assets/
        logo.png
  developers/
    .gitbook.yaml
    README.md
    SUMMARY.md
  changelog/
    .gitbook.yaml
    README.md
    SUMMARY.md
```

この `gitbook-docs.yaml` 各スペースをそれぞれのディレクトリにマッピングします：

{% code title="gitbook-docs.yaml" %}

```yaml
$schema: https://api.gitbook.com/gitbook-docs.yaml
site:
  structure:
    - type: space
      key: documentation
      title: ドキュメント
      path: documentation
      content:
        directory: ./documentation
    - type: space
      key: developers
      title: 開発者
      path: developers
      content:
        directory: ./developers
    - type: space
      key: changelog
      title: 更新履歴
      path: changelog
      content:
        directory: ./changelog
```

{% endcode %}

### スペースのコンテンツを自己完結させる

各スペースは、割り当てられたディレクトリのみを同期します。GitBook は、マッピングされたディレクトリ間でコンテンツやアセットを自動的に共有しません。

参照されるすべてのアセットは、必ずそのスペースのマッピングされたディレクトリ内に配置してください。複数のスペースでアセットが必要な場合は、各ディレクトリにコピーを追加するか、リポジトリを再編成してください。

サーバー側の `.gitbook.yaml` `ルート` この設定は、GitBook がそのスペースのマッピングされたディレクトリ内のどこからコンテンツを読み取るかを制御します。隣接するディレクトリを利用可能にはしません。

### マッピングされたディレクトリを移動する

ファイルとマッピングをまとめて更新して、スペースのコンテンツを移動します：

1. リポジトリ内で、スペースのコンテンツファイルとアセットを移動します。
2. では `gitbook-docs.yaml`そのスペースの `content.directory`を更新し、 `キー` は変更しないでください。
3. 両方の変更を同じコミットでコミットします。

{% hint style="info" %}
GitBook が両方の変更が存在する前にインポートすると、マッピングされたスペースが空に見える場合があります。
{% endhint %}

{% hint style="danger" %}
**を変更しないでください `キー` を新しいディレクトリに合わせて** キーとディレクトリ名は独立しています。スペースのキーを変更すると、そのスペースは新しいスペース ID を持つ別の新しいスペースに置き換えられ、元のキーに戻しても古い ID は復元されません。次を参照してください [キーはスペースを識別します](/docs/documentation/ja-gitbook-documentation/docs-as-code/git-sync/content-configuration.md#keys-identify-your-spaces).
{% endhint %}

GitBook によって生成されたキー — `space-1`, `space-2` — はディレクトリ名を反映しておらず、両者を揃えておく利点もありません。

### 個別スペース Git Sync を使用する

スペースに別のリポジトリやブランチが必要な場合は、個別スペース Git Sync を使用します。たとえば、非公開スペースを別々に同期する必要がある場合に使用します。

まず、サイトのコンテンツ マッピングからそのスペースを削除します。次に、そのスペースから Git Sync を構成します。

スペースを構成するには、次を参照してください [GitHub Sync を有効にする](/docs/documentation/ja-gitbook-documentation/docs-as-code/git-sync/enabling-github-sync.md) または [GitLab Sync を有効にする](/docs/documentation/ja-gitbook-documentation/docs-as-code/git-sync/enabling-gitlab-sync.md)。スコープの手順で、 **スペース Git Sync**.


---

# 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/ja-gitbook-documentation/docs-as-code/git-sync/monorepos.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.
