# GitHub

Integrate Better Stack with GitHub to **connect your repositories and enhance error context with `git blame` information**. This integration allows you to quickly pinpoint the exact code changes and authors associated with errors, streamlining your debugging process.

## Setting up the integration

1. Navigate to **Errors** → [Integrations](https://errors.betterstack.com/team/0/integrations/ ";_blank").
2. Find the **GitHub** integration and click **Add**.
3. Follow the authorization steps to connect your GitHub account.
4. Select the GitHub repositories you want to connect to Better Stack.
5. Click **Connect Selected**.

![GitHub integration settings](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/6a4220c9-d65a-43a3-f50f-b4ddd2f0ac00/md1x =1228x655)

## Git blame

*   **Automatic `git blame` data**: For errors with stack traces, Better Stack automatically fetches `git blame` information from your connected GitHub repositories.
*   **Identify relevant code changes**: See when and what code change introduced an error directly within the error details, including the commit hash and author.
*   **Faster debugging**: Quickly navigate to the relevant line of code in GitHub to inspect the change that might be causing the issue.

![Git blame example](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/a33cab01-00be-4ee5-36f2-0b4df0303d00/lg2x =1189x480)

### Configure git code paths

If the reported path to the source file in your error stack trace doesn't match the path in your repository, you can set up a mapping to correct this. This ensures that `git blame` functionality works correctly.

To configure code path mapping:

1.  Go to **Errors** → [Applications](https://errors.betterstack.com/team/t0/applications/ ";_blank").
2.  Click **Configure** in the dropdown menu of the application.
3.  Navigate to the **Advanced settings** tab.
4.  Under **Configure git code paths**, you'll find two options:
    *   **Stack trace root (prefix to match in stack traces)**: Enter the prefix of the file path as it appears in your stack traces (e.g., `/usr/src/app`).
    *   **Source code root (Replacement prefix for the repository)**: Enter the corresponding relative path to your source code within your repository (e.g., `apps/backend`).

![Code mapping settings](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/a5e2b2cc-68be-43a7-9157-94363fedf200/md1x =1186x312)