> ## Documentation Index
> Fetch the complete documentation index at: https://docs.newly.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect GitHub

> Keep your project's code in your own GitHub repository, kept in step with Newly both ways.

Newly keeps a copy of every project's code itself. Connecting GitHub puts that code in a repository **you own** as well, and keeps the two in step in both directions: what the agent builds appears on GitHub, and what you or your team push on GitHub reaches your chats.

Nothing about your project changes when you connect. Newly keeps its own copy either way, so a mistake on GitHub cannot take your work with it.

Everything here lives in your project's **Integrations** tab, under **GitHub**. Only an organization owner or admin can connect, sync or change the repository. Other members can see it.

## Connect your account

You install the Newly app on your GitHub account once. After that every project in your workspace can use it.

**1. Open the GitHub panel**

Open **Integrations** in the project's sidebar and choose **GitHub**.

**2. Install the app**

Select **Connect GitHub**. Your browser opens GitHub, where you choose the account and which repositories the app may touch. The panel notices when you finish and moves on by itself.

Newly links the installation on your own GitHub account, or on an organization you belong to. It never links someone else's personal installation, even one you can reach as a collaborator. If you ask an organization's owners to install the app, GitHub sends them the request. Once one of them approves it, select **Connect GitHub** again.

To use a repository that belongs to an organization, install the Newly app on that organization too.

You can also do this from a chat: ask the agent to put your code on GitHub and it shows a **Connect GitHub** card. It installs the app, then creates a new repository for the project, without leaving the conversation. To link a repository you already have, use the panel.

## Give the project a repository

Once your account is connected, each project needs a repository. You can create a new one or use one you already have.

### Create a repository

Give it a name and leave **Private** checked, or uncheck it for a public repository. Select **Create repository**. Newly creates it in your own GitHub account and pushes the project's full history into it.

### Use a repository you already have

Under **Or use a repository you already have**, paste its address, such as `https://github.com/you/your-app`, and select **Use this repo**. Newly works in that repository and pushes every change to it.

* You need push access to the repository.
* Its default branch must be `main`. If it isn't, rename the default branch to `main` on GitHub (Settings, then Branches) and try again.
* An empty repository is linked at once.
* If the repository has commits this project doesn't have, Newly asks first: **Put this project's code on top of** the repository? If you select **Put our code on top**, Newly adds one commit on top of its `main`. Your GitHub history stays as it is, and the files on `main` become this project's.
* A repository that another Newly project already syncs can't be linked. Select **Request access** to email that project's owner, who can add you.
* A repository you started a mobile app **from** can't be linked, because Newly never writes to it. Create a new repository instead.

> [!NOTE]
>
> To build a mobile app **from** a repository you already have, without changing it, see [Start from your Lovable or GitHub app](https://docs.newly.app/get-started/start-from-your-app.md).

## What syncs, and how quickly

| What happened | When it reaches the other side |
| - | - |
| Someone pushes to GitHub | Seconds |
| A chat finishes a turn | Saved to Newly at once, on GitHub within a minute |
| You merge a branch into `main` in the panel | At once |
| You select **Sync now** | At once, every branch, both directions |

Newly's internal working branches never reach your repository. Only the branches you can see in the panel are ever pushed.

## Branches

The panel lists your branches on both copies. Use the **In Newly / On GitHub** switch to see one copy at a time, and the search box once there are more than a few.

What you can do to a branch, from the **•••** next to it:

* **Rename** it on both copies at once.
* **Merge into `main`**.
* **Delete** it from both copies.
* **Push** a branch that only Newly has, which creates it on GitHub.

`main` and `dev` are the project's own two branches. They can't be renamed or deleted, here or on GitHub: if one is deleted on GitHub, Newly puts it back. If someone has already recreated it with different content, Newly puts its copy on a `newly-sync/` branch instead of overwriting theirs, so you can open a pull request and decide.

### New branches

**New branch** creates one on both copies at once. Start it from any branch, or paste a full commit SHA to start from an exact point in history.

### Which branch a chat uses

New chats start on the branch shown in **New chats start on** at the top of the Branches panel. That's a setting for the whole project.

To use a different branch for one chat only, select the branch name under the message box **before you send the first message** and pick another. That choice applies to that chat alone; every other chat still starts on the project default.

> [!NOTE]
>
> A chat's branch is fixed once it starts. You can't move an existing chat to another branch, which is why the picker disappears after the first message.

## History

**History** compares any two branches across both copies side by side. Pick a branch on each side, or swap them.

The row in the middle tells you where they stand:

| It says | What it means |
| - | - |
| **In sync at `abc1234`** | Both copies are on the same commit |
| **Diverged at `abc1234`** | Each side has commits the other doesn't, from that point on |
| **Common ancestor `abc1234`** | One side is ahead of the other |

Below that, each side's own commits are listed newest first, with who made them: **Newly** for the agent, **you** for your own, or the collaborator's name. **Show shared** reveals the history the two have in common, and **Changed files** lists the differences with the diffs inline.

## Collaborators

Invite someone by GitHub username and they get push access to the repository. They show as **invited** until they accept on GitHub, then **accepted**. Remove anyone from the same list. Past five people the list pages and gains a search box.

Invites are GitHub access, not Newly access. Sharing the Newly project is separate, and covered in [Share a project](https://docs.newly.app/code/sharing-projects.md).

## When a merge hits a conflict

If the same lines changed on both branches, the merge stops and nothing is changed on either side. The panel names the files involved and offers **Ask Newly to resolve**.

That hands the conflict to your chat as a message asking the agent to read both sides, keep the intent of each rather than discarding either, and tell you what it kept in each file. It stops and asks you when the two sides genuinely disagree rather than guessing.

> [!NOTE]
>
> The agent can only resolve a conflict on the branch its own chat is running on. If the conflict is on another branch, open a chat on that branch and ask there.

## Everything at once

Select **Actions** in the top right, or press <kbd>⌘K</kbd> on the web, for every action in the panel in one list: sync, open on GitHub, compare any two branches, create or push a branch, invite someone, disconnect, delete. Type to filter, arrow keys to move, Enter to run, Esc to close. Destructive actions arm their button rather than running from the list.

## Disconnecting

| Action | What happens |
| - | - |
| **Disconnect repository** | Newly syncs one last time, then the project stops syncing and goes back to Newly's own copy. The repository stays on GitHub. |
| **Delete repository on GitHub** | Newly backs the project up, disconnects, then deletes the repository. Asks twice first. |
| **Disconnect GitHub account** | Removes the Newly app from your account. Every project it was connected to goes back to Newly's own copy. |

If you delete the repository on GitHub yourself, the project keeps working from Newly's copy and simply shows as not connected.

## Related pages

> [card] [Where your code lives](https://docs.newly.app/code/where-your-code-lives.md)
>
> Branches, saved versions, and promoting to main.

> [card] [Get your code](https://docs.newly.app/code/get-your-code.md)
>
> Download your project with the newly CLI.

> [card] [Share a project](https://docs.newly.app/code/sharing-projects.md)
>
> Work on a project with other people in Newly.

> [card] [Undo and Restore to here](https://docs.newly.app/code/undo-and-restore.md)
>
> Go back to an earlier version of your code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.