# GitHub

Connect GitHub, link a repository, and work on issues, pull requests, branches and commits from the editor, by hand or with Lyna AI.

Connect your project to a GitHub repository, then push and pull, work on issues and pull requests, and follow the commits on GitHub without leaving the editor.

The editor in Code mode with the GitHub view open in the side bar and an issue page open in the editor area.

## What you can do

- Connect your GitHub account, then create a repository for your project or link one you have.
- Push your commits, pull the changes made on GitHub, and see if your branch is in sync.
- Browse the pull requests and issues of the repository, filter them by state and search them.
- Open any issue or pull request as a page in the editor: comment, edit, label, assign, close or reopen it.
- Merge a pull request, mark it ready for review or turn it back into a draft, request reviewers and review its changes.
- Create issues and pull requests with a Markdown description, labels, assignees, a milestone and reviewers.
- Use the branches made on GitHub, and delete a branch on GitHub from the branch menu or after a merge.
- See the commits on GitHub as a graph.
- Follow the workflow runs of the repository with their jobs, steps and logs, cancel or re-run them, and approve a deployment that waits for a review.
- Add a workflow from a template, on a new branch with its pull request or on the current branch.
- Ask Lyna AI to do all of this for you in the chat, with your approval for every change.

## Connect

1. ### Open the GitHub view

   In **Code** mode, choose **GitHub** in the views rail.
2. ### Connect GitHub

   Choose **Connect GitHub** and install the Lyna GitHub App on your account or on an organization. On GitHub, you choose which repositories the app can reach.
3. ### Create or link a repository

   - **Create Repository**: pick the **Owner** (your **Personal account** or an organization), a **Repository name** and its **Visibility**, **Public** or **Private**.
   - **Link Existing Repository**: search the repositories the app can reach, or type `owner/repo` and link it.

> [!NOTE]
>
> **Organizations**
>
> In an organization, an owner may have to approve the GitHub App first. Connect GitHub again once they do. If the app is installed on another GitHub account, install it on your own.

## The GitHub view

The top of the view shows the linked repository. Its name opens it on GitHub, and an icon marks a private one. Below it:

- **The sync status** of your current branch: **Up to date**, how many commits it is **ahead** of GitHub or **behind** it, **Not on GitHub yet** for a branch you have not pushed, or **Not checked yet**. **Check sync status** reads it again.
- **Push** and **Pull**.
- **More GitHub actions**: **Create Pull Request**, **Force Push**, **Pull with Rebase**, **Unlink Repository** and **Disconnect GitHub**.

The GitHub view with the linked repository, its sync status, the Push and Pull buttons, and the Issues tab with its state filter, search field and list.

Four tabs sit under the repository:

| Tab               | What it shows                                                                                                                                   |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **Pull requests** | The pull requests, with their state, checks and review state.                                                                                   |
| **Issues**        | The issues, with their labels, assignees and comment count.                                                                                     |
| **Commits**       | The commits on GitHub as a graph. See [Commits](#commits).                                                                                      |
| **Activity**      | The workflow runs (**Succeeded**, **Failed**, **In Progress**, **Queued**...) and the deployments of the repository. See [Activity](#activity). |

In **Pull requests** and **Issues**:

- **Show** filters the list: **Open**, **Closed** or **All**.
- The search field finds items by their words. The count of results shows next to it.
- The list loads more items as you scroll, so long histories stay fast.
- The button at the top creates a new item, and refresh reads the list again.
- Choose an item to open its page in the editor area. A tab you leave keeps its search, filter and scroll.

## Issues

An issue opens as a page in the editor area, beside your files.

An issue page in the editor area with its state, title, description and comments, the comment box with Write and Preview, and the side details: assignees, labels, milestone and development.

### Comment and close

The comment box takes Markdown. Use its toolbar or the shortcuts (`Cmd/Ctrl + B` bold, `Cmd/Ctrl + I` italic, `Cmd/Ctrl + K` link), switch between **Write** and **Preview**, then choose **Comment**.

- **Close issue** closes it as completed. **More ways to close** offers **Close as not planned**.
- With text in the box, the button becomes **Close with comment**: your comment is posted, then the issue closes.
- **Reopen issue** opens it again.

### Edit the issue

- **Edit title** and **Edit description** change the text in place.
- The side details hold **Assignees**, **Labels** and **Milestone**. Choose the gear of a section to pick values from the repository's own lists. You can assign up to 10 people.
- **Development** lists the branches and pull requests linked to the issue. **Create a branch** makes a branch for the issue on GitHub. It reaches your branches at once, and **Switch** checks it out. With uncommitted changes, commit them first, or switch from the branch menu, which can set them aside.
- **Sub-issues** shows their progress, and **Parent issue** links to the parent.

### More actions

- **Send to AI** puts the issue's text in the chat box, ready for Lyna AI. Nothing is sent until you read it and send it.
- **Open on GitHub** opens the issue on GitHub.
- The **More GitHub actions** menu has **Copy link**, **Lock conversation** (or **Unlock conversation**) and **Delete issue**.

> [!WARNING]
>
> **Deleting an issue**
>
> **Delete issue** removes the issue and its comments from GitHub for good. Only people with admin access to the repository can delete an issue, so Lyna offers it only when GitHub allows it. An action the GitHub App may not do is not offered.

Links in an issue ask before they leave Lyna, and an image from another site waits for your click, since anyone with access to the repository can write there.

## Pull requests

A pull request page has everything an issue page has (comments, title, description, labels, assignees, milestone, lock), plus:

- **A summary row**: its commits, the files changed, the lines added and removed, and **Review changes**.
- **Reviewers**: request up to 15 reviewers, and see each review state (**Approved**, **Changes asked**, **Commented**, **Pending**).
- **Checks**: how many passed, failed or are running, each with a **Details** link.
- **The merge box**: whether the pull request can merge, and why not.

A pull request page with its summary row, checks and merge box, and the merge options menu open on Merge pull request, Squash and merge, and Rebase and merge.

### Merge

The merge box says **Ready to merge**, or what blocks the merge: conflicts with the base branch, a rule of the base branch (reviews or required checks), failed or running checks, or a branch behind the base branch. Then:

| Choose                 | What happens                                          |
| ---------------------- | ----------------------------------------------------- |
| **Merge pull request** | All commits join the base branch with a merge commit. |
| **Squash and merge**   | The commits become one commit on the base branch.     |
| **Rebase and merge**   | The commits are added on top of the base branch.      |

Pick the method in **Merge options**. Lyna remembers it for your next merge. If someone pushed to the branch since the page loaded, GitHub refuses the merge: check the new commits, then merge again.

After the merge, or once you close a pull request without merging it, **Delete branch** removes its branch on GitHub.

### Drafts, closing and reopening

- **Ready for review** takes a draft out of draft. **Convert to draft** turns it back into a draft.
- **Close pull request** closes it without a merge. **Reopen pull request** opens it again.

### Review the changes

Choose **Review changes** to read every changed file and its diff. Select a line to comment on it, reply to a thread, then send your review: **Comment**, **Approve** or **Request Changes**, with a summary, and **Submit Review**.

## Create an issue or a pull request

New issues and pull requests open as pages in the editor area, laid out like the item page, and the created item takes the page's place. Leave the page to open something else and the draft waits for you. **Close** and **Cancel** ask before they throw away a draft.

### New issue

1. ### Open the page

   In the **Issues** tab, choose **New Issue**.
2. ### Write it

   Type the **Title**, then the **Description** in Markdown, with **Write** and **Preview**. In the side column, set the **Assignees**, **Labels** and **Milestone**.
3. ### Create it

   Choose **Create Issue**, or press `Cmd/Ctrl + Enter`. Turn on **Create more** to start the next issue right away.

The New Issue page with the title, the Markdown description in Preview, and the side column with assignees, labels and milestone.

### New pull request

1. ### Open the page

   In the **Pull requests** tab, choose **Create Pull Request**. It is also in **More GitHub actions**.
2. ### Pick the branches

   Choose the **Base branch** to merge into and the **From branch** with your work. The page says when a branch is not on GitHub yet: push it first.
3. ### Write it and create it

   Type the **Title** and the **Description**, set the **Assignees**, **Labels**, **Reviewers** and **Milestone**, then choose **Create Pull Request**. To open it as a draft, choose **Create Draft Pull Request** in **More ways to create**.

The New Pull Request page with the base and source branches, the title and description, and the side column with reviewers.

## Branches and sync

### Push and pull

| Control              | What it does                                                                                                    |
| -------------------- | --------------------------------------------------------------------------------------------------------------- |
| **Push**             | Sends your commits to GitHub.                                                                                   |
| **Pull**             | Brings in the changes made on GitHub. If they conflict with yours, you resolve the conflicts in Source Control. |
| **Pull with Rebase** | Brings in the changes, then puts your commits on top of them.                                                   |
| **Force Push**       | Replaces the history on GitHub with yours, after a confirmation.                                                |

Only committed work is pushed: commit in [Source Control](/features/code/git) first. Push and pull are also in the command palette once a repository is linked.

### The branch menu

The branch menu at the top of Source Control lists the branches made on GitHub too, with a cloud icon, and marks your branches that GitHub also has. Choose one to switch to it: a branch that is only on GitHub becomes a branch of your project that follows it.

The branch menu of Source Control open, with a branch made on GitHub marked by a cloud icon and the Delete a branch action.

### Delete a branch on GitHub

- **Delete a branch** in the branch menu deletes a branch that is only on GitHub after a confirmation. For a branch that is on both sides, turn on **Also delete it on GitHub**.
- **Merge a branch into this one** offers to delete the merged branch after the merge, on GitHub too.
- A merged or closed pull request offers **Delete branch** on its page.

When the project fetches, the branches deleted on GitHub leave the branch menu.

> [!WARNING]
>
> **Deleting a branch on GitHub**
>
> The branch is removed from the GitHub repository for everyone, and an open pull request from it is closed. A branch protected on GitHub cannot be deleted.

## Commits

The **Commits** tab shows the commits on GitHub as the same graph as Source Control: lanes, branch badges, and the files and changes of each commit.

- Search by message, hash or author.
- Choose which GitHub branches the graph shows: every branch on GitHub, or the branch your project tracks.
- **Fetch** reads the latest commits from GitHub. Files show as a list or a tree.
- A commit's menu opens it on GitHub, creates a branch from it, compares it, copies its hash or message, or adds it to the chat.

The Commits tab of the GitHub view with the search field, the graph toolbar and the commits of the GitHub branches drawn as a graph.

The graph shows once your project runs. While it starts, the tab says **Your project is starting**.

## Activity

The **Activity** tab lists the workflow runs of the repository, newest first. Each row says the run's state in words (**Queued**, **In Progress**, **Waiting**, **Succeeded**, **Failed**, **Cancelled**...), then its title, workflow, branch, who started it, when, and how long it took.

- **Status**, **Branch** and **Workflow** filter the runs on GitHub. **Branch** offers every branch or the branch your project is on.
- The search field finds loaded runs by their title, workflow, branch, author, run number or commit.
- The list loads more runs as you scroll, and follows the runs that move: a run that ends shows its result without a refresh.
- The deployments of the repository show under the runs.

The Activity tab of the GitHub view with its filters and a failed run, and the run page open in the editor area with its jobs, its steps and the log open on the failed step.

### Add a workflow

Choose **New Workflow** in the **Activity** tab (an empty repository offers it too). The page opens in the editor area, with the form beside a preview of the file.

1. Pick a **Template**:
   - **CI** runs the project's checks (**Typecheck**, **Test**, **Build**) on each push and pull request to the branch you name in **Branch That Triggers It**.
   - **Scheduled** runs one script on a schedule: every day, every Monday, or your own cron expression in UTC.
   - **Manual** runs one script when you start it from GitHub.
   - **Deploy** builds the project and keeps the folder the build writes, such as `dist`, when you publish a release.
2. Give it a **Name**. The file is saved under `.github/workflows/`, with a file name made from it.
3. Choose what it runs. A workflow runs only the scripts of your project's `package.json`: the pickers list them, a check with no script is off and says why, and a template with no script to run says so and keeps **Create Workflow** off. Pick the **Package Manager** and the version the run uses.
4. Choose **Where It Goes**:
   - **A new branch with a pull request**, the default: the file is written on a new branch with a pull request into the default branch, and runs once you merge it.
   - **The current branch**: the file is written on the branch your project is on, with a pull request into the default branch. On the default branch itself, it runs from the next push.
5. Check the **Preview**: it shows the file as it will be written and the result of the workflow checks. A field in red says what to fix. Each template asks GitHub only for the access it needs and uses fixed versions of its actions.
6. Choose **Create Workflow**, or press `Cmd/Ctrl + Enter`. A message confirms it, with **Open Pull Request** when a pull request was opened, and the page closes. **Activity** reads the runs again, so a run the new workflow starts shows there a few seconds later.

A refused workflow keeps the page open with your settings: a name already taken, a branch that already exists, or a missing permission.

### The run page

Choose a run to open its page in the editor area. It shows the run's state, its workflow, branch, commit, event, who started it, when it started and how long it took, with **Open on GitHub**.

- **Jobs** lists the jobs with their state and duration. The first failed job opens on its own.
- Under the chosen job, its steps show with their state. Choose a step to go to it in the log.
- The log opens on the failed step. Search it, show the **Timestamps**, copy it with **Copy Log**, or open the whole log on GitHub when it is long.
- While a job runs, its steps update live. GitHub gives a job's log once the job ends, so the log shows then.

### Act on a run

| Action                    | What it does                                                            |
| ------------------------- | ----------------------------------------------------------------------- |
| **Cancel Run**            | Stops the jobs still running, after a confirmation.                     |
| **Force Cancel**          | Stops the run at once when a cancel did not end it.                     |
| **Re-run All Jobs**       | Runs every job of the run again.                                        |
| **Re-run Failed Jobs**    | Runs again only the jobs that failed, and the jobs that depend on them. |
| **Re-run Job**            | Runs the chosen job again, once it ended.                               |
| **Approve** or **Reject** | Answers a deployment that waits for your review. **Reject** asks first. |

> [!NOTE]
>
> **Permissions on GitHub**
>
> To change runs, the Lyna GitHub App needs write access to Actions on your repository, to Deployments to review a deployment, and to Workflows to add a workflow. When it is missing, Lyna says so and links to the app's permissions on GitHub (**Open App Permissions**).

## Ask Lyna AI

In the chat, ask Lyna AI in your own words. It can:

- Show the GitHub status of the project: the repository, the branch and its sync. With nothing connected, the card offers **Connect GitHub**, or **Link a repository**.
- List and read issues and pull requests.
- Create, comment on, close, reopen, edit or delete an issue, and create a branch for an issue.
- Open, merge, close or reopen a pull request, and mark it ready for review or as a draft.
- Push and pull, and read the commits on GitHub.
- List the workflow runs, read the log of a failed job, re-run or cancel a run, and start a workflow.
- Add a workflow from a template (checks on each push, a scheduled or manual task, a deploy) on a new branch with its pull request. The workflow runs only the scripts your project has.

The chat with a GitHub list card of open issues and an issue card with its Open and Open on GitHub buttons.

Each answer shows a card. A list card opens an item's page when you choose its row. An item card has **Open**, which opens the item's page in the editor, and **Open on GitHub**. A pull that leaves conflicts offers **Resolve conflicts**.

> [!NOTE]
>
> **You approve every change on GitHub**
>
> Lyna AI reads your issues, pull requests, commits and runs on its own, but every change on GitHub (an issue, a comment, a merge, a branch, a push, a pull, a run or a workflow) waits for your approval in the chat. Choose **Allow Once** to let it happen, or **Deny**.

## Unlink or disconnect

- **Unlink Repository** removes the link between the project and the repository, after a confirmation. The repository stays on GitHub.
- **Disconnect GitHub** removes the Lyna GitHub App from your account. Every project loses access to its repository until you connect again. Nothing is deleted on GitHub.

## Related

- [Git](/features/code/git): Changes, commits and branches.
- [Branch graph](/features/code/branch-graph): See your history as a graph.
- [GitHub and pull requests](/features/code/github-and-pull-requests): The GitHub view in the code editor.
- [Chat](/features/ai/chat): Ask Lyna AI to build and change your project.
