# GitHub and GitHub Enterprise Server

> Connect GitHub or GitHub Enterprise Server to MergeHarbor with the MergeHarbor GitHub App: install it, choose repositories, permissions and status checks.

MergeHarbor connects to GitHub through a GitHub App, which grants access only to the repositories you select.

## Install the app

1. In the console, open **Integrations → Code hosts** (or the setup checklist) and choose **GitHub**.
2. Choose the GitHub account or organization and the repositories to grant.
3. GitHub returns you to MergeHarbor, which confirms that your GitHub account can access the installation, attaches it to your organization, and starts indexing.

If your GitHub organization requires an owner to approve app installations, the setup shows **Installation requested — waiting for an owner to approve** until an owner approves it on GitHub.

## Permissions

| Permission                | Access         | Used for                                                                                 |
| ------------------------- | -------------- | ---------------------------------------------------------------------------------------- |
| Contents                  | Read and write | Reading code to index and review; fix pull request branches and merging from the console |
| Metadata                  | Read           | Listing repositories                                                                     |
| Pull requests             | Read and write | Posting reviews and comments                                                             |
| Checks                    | Read and write | The MergeHarbor status check                                                             |
| Issues                    | Read           | Receiving `@mergeharbor` commands in pull-request conversations                          |
| Members (organization)    | Read           | Team sync and GitHub account linking                                                     |
| Email addresses (account) | Read           | Sign in with GitHub                                                                      |

Events: pull request, issue comment, pull request review comment, push, installation, and installation repositories. The pull request review comment event lets MergeHarbor answer questions asked in reply to its review comments.

See [Code host permissions](https://mergeharbor.com/docs/permissions) for why each permission is needed and how to revoke access.

## Reconnect, disconnect and moved repositories

- **Reconnect** or **Connect another** (Integrations → Code hosts) opens GitHub. Choosing the same account updates its installation; choosing another account or organization connects that installation as another code host.
- **Disconnect** stops reviews at once. The MergeHarbor app stays installed on GitHub but is ignored until it is connected again; uninstall it on GitHub to remove its access. The repositories' reviews, index and settings are kept for 7 days, then permanently deleted. Uninstalling the app does the same.
- Connecting an installation that can see those repositories within the 7 days brings them back with their history, enabled as they were. This works with the same installation or another one, so a repository transferred to another account comes back as the same repository under its new name.
- When a repository moves between two installations that are both connected, its history, settings and index follow it.
- A repository belongs to one MergeHarbor organization at a time, and an installation can be connected to one organization.

## GitHub Enterprise Server

GitHub Enterprise Server is supported in [self-hosted](https://mergeharbor.com/docs/self-hosting) deployments: your operator registers the MergeHarbor GitHub App on your instance and points MergeHarbor at it. MergeHarbor Cloud connects to github.com.

## Status checks

Make **MergeHarbor** a required status check in your branch protection rules to gate merges on review results. Configure when the check fails in [Configure reviews](https://mergeharbor.com/docs/configuration#mergeharboryml-reference).
