# GitHub and GitLab

> Connect GitHub or GitLab (including self-hosted GitHub Enterprise and GitLab) so commits and pull/merge requests that mention a task key show up on that task.

Source: https://docs.sofiaspace.uz/integrations/github-gitlab/

Connect your code hosting and every commit, pull request and merge request that mentions a task key — such as `WEB-142` — appears on that task automatically, with its author, time and state.

**Who can connect:** Org Admins. **Who sees the links:** anyone who can open the task. **Where:** **Settings → Integrations → Code hosting**.

## Connect GitHub

1. Choose **Connect GitHub**.
2. GitHub opens: install the Sofia Space app and pick all repositories or only some.

The app only reads code, metadata and pull requests. It can't push code or change anything.

## Connect GitLab

1. Choose **Connect GitLab** and sign in to GitLab.
2. Pick the GitLab **group** to connect. Every project in that group is set up automatically.

Projects added to the group later need the group to be reconnected. **Needs reconnect** next to a connection means its access expired or was revoked — disconnect and connect again.

Use **Connect another** to add more organisations or groups, and **Sync now** to fetch recent activity straight away.

## Link work to tasks

Put the task key anywhere in:

- a **commit message**, or
- a **pull/merge request's title or description**.

```text
WEB-142 Fix the login redirect
```

Branch names are **not** read — put the key in the commit message or PR title.

The link appears in the task's **Development** section. A pull request keeps one entry that updates as it moves from **open** to **merged** or **closed**. Keys that don't match a real task are ignored.

Tip: the **copy key** button in a task's header puts the key on your clipboard for a commit message.

## Self-hosted GitHub Enterprise or GitLab

For GitHub Enterprise Server, a self-managed GitLab, or an app your organization owns, choose **Use your own app** on the provider's row. Sofia Space can create the GitHub App for you, and you can pick **Webhooks** or **Polling** (every 5 minutes) for delivery. The full guide is [Self-managed GitHub and GitLab](https://docs.sofiaspace.uz/integrations/github-gitlab-self-managed.md).

## Check the connection

Each connection on the **Code hosting** card shows when it was connected and last synced (**Connected {date} · synced {time}**, **not synced yet**, or **last sync failed**).

- **Sync now** fetches recent activity immediately and reports how many repositories, commits and pull/merge requests it read.
- **Needs reconnect** means access expired or was revoked on the Git host — disconnect and connect again.

## Troubleshooting

**A commit doesn't show on the task.**
Check the key is in the commit message (or the pull/merge request title or description), that it matches a real task such as `WEB-142`, and that the repository is one the app was installed on. Then choose **Sync now**. Branch names aren't read.

**A new GitLab project isn't tracked.**
Projects added to a group after you connected it aren't picked up. Reconnect the group.

**I can't see Settings → Integrations.**
Only Org Admins can open it. Everyone who can open a task sees its **Development** links.

## What you can't do

- You can't connect Bitbucket or Azure DevOps.
- You can't create branches, commits or pull requests from Sofia Space; the integration only reads.
- You can't link work by branch name.
- You can't link one commit to tasks in another workspace.

## Disconnect

**Disconnect** in **Settings → Integrations** stops tracking new activity right away. Links already on tasks stay.
