> 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 を使用して、1 つのリポジトリとブランチから複数のスペースを同期します。各スペースをそれぞれのディレクトリにマッピングします。 `docs.yaml`.

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

サイトの **プロジェクト ディレクトリ** が Git Sync のインストール ディレクトリを設定します。 `docs.yaml` そこにあります。空のままにすると、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 はマッピングを `docs.yaml`.

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

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

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

```
/
  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
```

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

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

```yaml
$schema: https://api.gitbook.com/openapi.yaml#/components/schemas/GitSyncSiteConfig
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. で `docs.yaml`、そのスペースの `content.directory`.
3. 両方の変更を同じコミットでコミットします。

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

### 個別スペースの 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)の手順に従います。スコープの手順で、 **Space 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 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/docs-as-code/git-sync/monorepos.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.
