> 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/settings/git-integrations/connecting-a-github-repository.md).

# Connecting a GitHub Repository

## ![](https://1800549522-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) Overview

This article shows you how to connect your GitHub repository to DevOps so that Salesforce metadata managed in DevOps branches syncs automatically with your GitHub repository. This ensures that your branches, commits, and pull requests are fully tracked in your Git-based version control system.

{% hint style="info" %}

#### GitHub Personal Access Tokens

DevOps connects to a GitHub repository using a Personal Access Token. You can use either a **Classic** token or a **Fine-Grained** token, depending on your company's requirements. The instructions below cover both methods, but you only need to create one type of token.
{% endhint %}

## GitHub Prerequisites

{% stepper %}
{% step %}

### Repository

The DevOps-to-GitHub integration syncs all branches, commits, and pull requests to a single GitHub repository. This repository can be public or private and can be owned by an organization or an individual user.

The screenshot below shows a private repository **flosum-devops-example** that is part of the **Flosum-Example** organization.

<div align="left"><figure><img src="https://1800549522-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 %}

### Personal Access Token - Classic

{% hint style="info" %}
A **Classic** token applies to every repository your GitHub account can access and needs only two scopes. The following instructions explain how to create one.
{% endhint %}

1. Log in to your GitHub account.
2. Click your profile picture in the upper-right corner to open the dropdown menu.
3. Click **Settings**.
4. Access **Developer settings > Personal access tokens > Tokens (classic)**.
5. Click the **Generate new token** dropdown menu.
6. Click **Generate new token (classic)**.

   <div align="left"><figure><img src="https://1800549522-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. Enter a description of the token in the **Note** textbox.
8. Click the **Expiration** dropdown and select the date when you want the token to expire.
9. Select the following **Scopes**:
   1. **repo**
   2. **workflow**

      <div align="left"><figure><img src="https://1800549522-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. Click **Generate token** at the bottom of the page.
11. Copy the token and save it securely. You will need this token when connecting DevOps to your GitHub account.
    {% endstep %}

{% step %}

### Personal Access Token - Fine-Grained

{% hint style="info" %}
A **Fine-Grained** token is limited to the repositories and permissions you select, so it gives DevOps narrower access than a **Classic** token. The following instructions explain how to create one.
{% endhint %}

1. Log in to your GitHub account.
2. Click your profile picture in the upper-right corner to open the dropdown menu.
3. Click **Settings**.
4. Access **Developer settings > Personal access tokens > Fine-grained tokens**.
5. Click **Generate new token**.&#x20;

   <div align="left"><figure><img src="https://1800549522-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. Enter a name for the token in the **Token name** textbox.
7. Click the **Resource owner** dropdown and select the user or organization that owns the repository this token is for.
8. Click the **Expiration** dropdown and select the date when you want the token to expire.
9. Under **Repository access**, select **Only select repositories** to limit the scope of this token to only the repositories you select.

{% hint style="info" %}
You can also select **All repositories**, but the token will then have access to any new repositories added to the **Resource owner**.

Do not select **Public repositories**. This option grants read-only access, and the DevOps GitHub integration requires read and write permissions.
{% endhint %}

10. Click the **Select repositories** dropdown and check all the repositories to include with this token.&#x20;

    <div align="left"><figure><img src="https://1800549522-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. Under **Permissions**, click **Add permissions** to add each of the permissions in the table below.
12. Set the **Access** dropdown for each permission to match the Access column in the table below.

<table><thead><tr><th width="160.333251953125">Permission</th><th>Access</th></tr></thead><tbody><tr><td><strong>Administration</strong></td><td>Read and write</td></tr><tr><td><strong>Contents</strong></td><td>Read and write</td></tr><tr><td><strong>Metadata</strong></td><td>Read-only</td></tr><tr><td><strong>Webhooks</strong></td><td>Read and write</td></tr></tbody></table>

{% hint style="info" %}
The **Metadata** permission is added automatically when another permission is added.
{% endhint %}

13. Click **Generate token**.&#x20;

    <div align="left"><figure><img src="https://1800549522-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. Review the token's settings in the confirmation dialog and click **Generate token**.
15. Copy the token and save it securely. You will need this token when connecting DevOps to your GitHub account.
    {% endstep %}
    {% endstepper %}

## Connect DevOps to GitHub

{% stepper %}
{% step %}

### Access Git Integration Settings

1. Click **Git integration** under the **Settings** section in the left sidebar menu.
2. Click the **Settings** tab.&#x20;

   <div align="left"><figure><img src="https://1800549522-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 %}

### Connect GitHub

1. Click the **Service type** dropdown menu.
2. Select **GitHub**.&#x20;

   <div align="left"><figure><img src="https://1800549522-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. In the **Organization** textbox, enter the GitHub organization name that owns the repository you are connecting to. Leave blank if connecting to a repository owned by your GitHub user account.

{% hint style="info" %}

#### Repository Path

The GitHub repository path the integration tries to connect to depends on whether the **Organization** field has a value.

If the **Organization** field has a value, the repository path is:

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

If the **Organization** field is blank, the repository path is:

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

4. In the **Username** textbox, enter the GitHub username you are connecting this integration with.
5. In the **Token** textbox, enter the GitHub Personal Access Token you created in the section above.
6. In the **Repository name** textbox, enter the name of the GitHub repository you are connecting to.&#x20;

   <div align="left"><figure><img src="https://1800549522-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. Click **Connect**.

   <div align="left"><figure><img src="https://1800549522-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. If the Git integration connects to your GitHub repository successfully, a success message appears. The **GitHub** connection then lists the organization and shows its status as **Connected**.

   <div align="left"><figure><img src="https://1800549522-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" %}
If the Git integration connection fails, check the error message to determine the cause. Once fixed, try connecting again.
{% endhint %}
{% endstep %}

{% step %}

### GitHub Synchronization

Once connected, all DevOps branches will begin to sync with the GitHub repository. You can check the sync progress in the **Activities** tab.

<div align="left"><figure><img src="https://1800549522-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 Repository

The screenshot below shows an example of a GitHub repository that is connected to and synced with DevOps.

<div align="left"><figure><img src="https://1800549522-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/settings/git-integrations/connecting-a-github-repository.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.
