> For the complete documentation index, see [llms.txt](https://docs.flosum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flosum.com/devops/devops-ja/she-ding/git-tong-he/github-ripojitorino.md).

# GitHub リポジトリの接続

## ![](https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FG5ZbxX918xOHwbAwAJ4n%2FSummary2-Small-Icon.svg?alt=media\&token=da26a67f-ff7f-47b3-8669-06be960dc2d7) 概要

この記事では、GitHub リポジトリを DevOps に接続し、DevOps ブランチで管理されている Salesforce メタデータを GitHub リポジトリと自動的に同期する方法を説明します。これにより、ブランチ、コミット、プルリクエストが Git ベースのバージョン管理システムで完全に追跡されます。

{% hint style="info" %}

#### GitHub の個人用アクセストークン

DevOps は Personal Access Token を使用して GitHub リポジトリに接続します。使用できるのは、 **従来型** トークンまたは **きめ細かな** トークンのどちらかです。会社の要件に応じて選択してください。以下の手順では両方の方法を説明しますが、作成する必要があるのはどちらか一方の種類のトークンだけです。
{% endhint %}

## GitHub の前提条件

{% stepper %}
{% step %}

### リポジトリ

DevOps と GitHub の統合は、すべてのブランチ、コミット、プルリクエストを 1 つの GitHub リポジトリに同期します。このリポジトリは公開または非公開のいずれでもよく、組織または個人ユーザーが所有できます。

下のスクリーンショットは、非公開リポジトリを示しています **flosum-devops-example** で、 **Flosum-Example** 組織の一部です。

<div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FazsmfMfBSN86T57yekof%2FConnectingAGithubRepo-GitHub-S01-01.png?alt=media&amp;token=76401d1a-6364-4be3-9bc1-905623afe76d" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### 個人用アクセストークン - 従来型

{% hint style="info" %}
1つの **従来型** トークンは、GitHub アカウントからアクセスできるすべてのリポジトリに適用され、必要なスコープは 2 つだけです。以下の手順で作成方法を説明します。
{% endhint %}

1. GitHub アカウントにログインします。
2. 右上のプロフィール画像をクリックして、ドロップダウンメニューを開きます。
3. クリックします **設定**.
4. アクセス **開発者設定 > 個人用アクセストークン > トークン（従来型）**.
5. 次を **新しいトークンを生成** ドロップダウンメニュー。
6. クリックします **新しいトークンを生成（従来型）**.

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FpaZvnojf1QgRHtTc0Lwu%2FConnectingAGithubRepo-GitHub-S02-01.png?alt=media&amp;token=2e312514-ab4b-4147-b91d-08b2acf5dc4f" alt="" width="563"><figcaption></figcaption></figure></div>
7. トークンの説明を **ノート** テキストボックスに入力します。
8. 次を **有効期限** のドロップダウンを開き、トークンの有効期限を設定する日付を選択します。
9. 次の **スコープ**:
   1. **repo**
   2. **workflow**

      <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FkZxDlpbIm22nPJODbFEt%2FConnectingAGithubRepo-GitHub-S02-02.png?alt=media&amp;token=5d4c4b87-85e4-4cdb-b0ef-37714b84e290" alt="" width="563"><figcaption></figcaption></figure></div>
10. クリックします **トークンを生成** をページ下部でクリックします。
11. トークンをコピーして、安全な場所に保存します。DevOps を GitHub アカウントに接続するときにこのトークンが必要になります。
    {% endstep %}

{% step %}

### 個人用アクセストークン - きめ細かな

{% hint style="info" %}
1つの **きめ細かな** トークンは、選択したリポジトリと権限に限定されるため、DevOps に対しては **従来型** トークンよりも狭いアクセス権しか与えません。以下の手順で作成方法を説明します。
{% endhint %}

1. GitHub アカウントにログインします。
2. 右上のプロフィール画像をクリックして、ドロップダウンメニューを開きます。
3. クリックします **設定**.
4. アクセス **開発者設定 > 個人用アクセストークン > きめ細かなトークン**.
5. クリックします **新しいトークンを生成**.&#x20;

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FPbZ7SfKJditlzAIFJ2Zr%2FConnectingAGithubRepo-GitHub-S03-001.png?alt=media&amp;token=4c204ce1-1f9b-4ddd-a0a3-152ad56b146b" alt="" width="563"><figcaption></figcaption></figure></div>
6. トークン名を **トークン名** テキストボックスに入力します。
7. 次を **リソース所有者** ドロップダウンで、このトークンの対象となるリポジトリの所有者であるユーザーまたは組織を選択します。
8. 次を **有効期限** のドロップダウンを開き、トークンの有効期限を設定する日付を選択します。
9. 〜の下で **リポジトリアクセス**、 **選択したリポジトリのみ** を選択して、このトークンのスコープを選択したリポジトリのみに制限します。

{% hint style="info" %}
また、 **すべてのリポジトリ**を選択することもできますが、その場合、トークンは **リソース所有者**.

選択しないでください **公開リポジトリ**。このオプションは読み取り専用アクセスを付与しますが、DevOps の GitHub 統合には読み取りおよび書き込み権限が必要です。
{% endhint %}

10. 次を **リポジトリを選択** ドロップダウンで、このトークンに含めるすべてのリポジトリにチェックを付けます。&#x20;

    <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FSMXbBF35yZu84A87vs5S%2FConnectingAGithubRepo-GitHub-S03-002.png?alt=media&amp;token=6053ecec-9344-476c-b98c-5cea5c0029be" alt="" width="563"><figcaption></figcaption></figure></div>
11. 〜の下で **権限**、 **権限を追加** をクリックして、下の表の各権限を追加します。
12. 各権限の **アクセス** ドロップダウンを下の表のアクセス列に合わせて設定します。

<table><thead><tr><th width="160.333251953125">権限</th><th>アクセス</th></tr></thead><tbody><tr><td><strong>管理</strong></td><td>読み取りと書き込み</td></tr><tr><td><strong>コンテンツ</strong></td><td>読み取りと書き込み</td></tr><tr><td><strong>メタデータ</strong></td><td>読み取り専用</td></tr><tr><td><strong>Webhook</strong></td><td>読み取りと書き込み</td></tr></tbody></table>

{% hint style="info" %}
その **メタデータ** 権限は、別の権限が追加されると自動的に追加されます。
{% endhint %}

13. クリックします **トークンを生成**.&#x20;

    <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FrMbsrOUAvq8ceA6tOJus%2FConnectingAGithubRepo-GitHub-S03-003.png?alt=media&amp;token=8e5f7089-59b5-4407-a56e-7804515dc12d" alt="" width="563"><figcaption></figcaption></figure></div>
14. 確認ダイアログでトークンの設定を確認し、 **トークンを生成**.
15. トークンをコピーして、安全な場所に保存します。DevOps を GitHub アカウントに接続するときにこのトークンが必要になります。
    {% endstep %}
    {% endstepper %}

## GitHub に DevOps を接続

{% stepper %}
{% step %}

### Git 統合の設定にアクセス

1. クリックします **Git 統合** 左側のサイドバーメニューの **設定** セクションの下にある
2. 次を **設定** タブ。&#x20;

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fn2iJ57iJHKLCez5xbLYG%2FConnectingAGithubRepo-DevOps-S01-001.png?alt=media&amp;token=bd2284a7-c016-49d8-81d5-b87c77395786" alt="" width="563"><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}

### GitHub に接続

1. 次を **サービス種別** ドロップダウンメニュー。
2. 選択 **GitHub**.&#x20;

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FlvwIqq1CUyrV4IiPUfkc%2FConnectingAGithubRepo-DevOps-S02-002.png?alt=media&amp;token=10162ccd-b7fd-4dd8-a597-9b5210a29367" alt="" width="563"><figcaption></figcaption></figure></div>
3. 〜の **組織** テキストボックスに、接続先リポジトリを所有している GitHub 組織名を入力します。GitHub ユーザーアカウントが所有するリポジトリに接続する場合は空白のままにします。

{% hint style="info" %}

#### リポジトリパス

統合が接続を試みる GitHub リポジトリのパスは、 **組織** フィールドに値があるかどうかによって異なります。

もし **組織** そのフィールドに値がある場合、リポジトリパスは次のとおりです。

* `github.com/{Organization}/{Repository name}`

もし **組織** フィールドが空白の場合、リポジトリパスは次のとおりです。

* `github.com/{Username}/{Repository name}`
  {% endhint %}

4. 〜の **ユーザー名** テキストボックスに、この統合に接続する GitHub ユーザー名を入力します。
5. 〜の **トークン** テキストボックスに、上記のセクションで作成した GitHub Personal Access Token を入力します。
6. 〜の **リポジトリ名** テキストボックスに、接続する GitHub リポジトリ名を入力します。&#x20;

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FPC0TH2ymtM7oQp5qF31d%2FConnectingAGithubRepo-DevOps-S02-003.png?alt=media&amp;token=bb586127-dbb3-432c-ace6-1c4b137037b3" alt="" width="563"><figcaption></figcaption></figure></div>
7. クリックします **接続**.

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FOLkm73Dhx11cSBIOFpIt%2FConnectingAGithubRepo-DevOps-S02-004.png?alt=media&amp;token=4bc772c6-d5af-4aec-9fd7-77d8c0b30d31" alt="" width="563"><figcaption></figcaption></figure></div>
8. Git 統合が GitHub リポジトリに正常に接続されると、成功メッセージが表示されます。 **GitHub** その接続には組織が一覧表示され、ステータスは **接続済み**.

   <div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FIm5tozrnwFr7UrMSkQ03%2FConnectingAGithubRepo-DevOps-S02-005.png?alt=media&amp;token=872f6fff-151a-4c3d-bd6a-8f272f799881" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="warning" %}
Git 統合の接続に失敗した場合は、エラーメッセージを確認して原因を特定してください。修正したら、再度接続を試してください。
{% endhint %}
{% endstep %}

{% step %}

### GitHub の同期

接続後、すべての DevOps ブランチの GitHub リポジトリとの同期が開始されます。同期の進行状況は **アクティビティ** タブ。

<div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2FmrV2G6S4p7jYyaZz9PCy%2FConnectingAGithubRepo-DevOps-S03-006.png?alt=media&amp;token=ae3f2c69-880c-4133-a1c7-6a17f981645e" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### GitHub リポジトリ

下のスクリーンショットは、DevOps に接続され、DevOps と同期されている GitHub リポジトリの例を示しています。

<div align="left"><figure><img src="https://225042527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRpUu5iMlzMFAudyBvMOl%2Fuploads%2Fnxj6jqKZ8QvYnjZNg8s8%2FConnectingAGithubRepo-DevOps-S04-01.png?alt=media&amp;token=7aa9df5e-f685-4c5f-94e4-dcd2b3f38a9e" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}
{% endstepper %}


---

# 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://docs.flosum.com/devops/devops-ja/she-ding/git-tong-he/github-ripojitorino.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.
