# Branches

Branches in Nected allow teams to work in parallel without affecting production. Every Rule, Workflow, Dataset, Integration, and Variable you create or modify is isolated to the currently selected Git branch until you commit and push your changes.

When connected to GitHub, Nected automatically imports your repository’s branch structure and lets users switch to any branch they have permission to access.

### **How Branch Access Works?**

Branch visibility in Nected fully depends on the user’s GitHub permissions:

#### **Workspace Owner / Repository Owner**

* Sees **all branches** from the connected repository
* Can **push and pull** on every branch
* Can select any branch as default

#### **Workspace Members with Limited Access**

* Only see branches they have **explicit GitHub permissions** for
* Can **push/pull** only on those authorized branches
* Cannot access protected or restricted branches unless granted permission in GitHub

This ensures that GitHub remains the single source of truth for branch security and governance.

## **Giving Branch Access via Fine-Grained Personal Access Tokens**

[Fine-grained Personal Access Tokens](https://docs.github.com/en/rest/authentication/permissions-required-for-fine-grained-personal-access-tokens?apiVersion=2022-11-28) (PATs) allow a GitHub repository owner to grant **precise, branch-level permissions** to workspace admins who will be working inside Nected. This ensures users can Push/Pull on specific branches without exposing the entire repository.

Repository owners can control which branches a workspace admin can push to by combining three GitHub features:\
**repo-scoped Fine-grained PAT**, **collaborator permissions**, and **branch protection rules**.\
This allows the admin to *see* all branches but *push* only to specific ones.

{% stepper %}
{% step %}

### Add the User as a Collaborator

Give the workspace admin **Write** access to the repository (not Admin).\
This grants visibility into all branches and allows their PAT to authenticate.
{% endstep %}

{% step %}

### Create a Fine-grained Personal Access Token

Generate a Fine-grained PAT and scope it to the specific repository.\
Under Repository Permissions, set:\
**Contents → Read & Write**\
Avoid granting broader admin permissions.\
The admin will add this PAT inside Nected.
{% endstep %}

{% step %}

### Protect Branches You Want to Restrict

Use GitHub’s Branch Protection Rules to block direct pushes to branches you want controlled (e.g., `main`, `prod`).\
Enable: “Restrict who can push to matching branches”\
Add only approved users or teams.\
The workspace admin will still see these branches but cannot push to them.
{% endstep %}

{% step %}

### Allow Push Access to Specific Branches

Leave the allowed branch (e.g., `branch-x`) **unprotected**, enabling the admin to push changes freely.\
All other branches require PRs and approval workflows in GitHub.
{% endstep %}
{% endstepper %}

## **Creating Branches**

Branch creation must be done in **GitHub**, not in Nected.

To create a new branch, follow GitHub’s documentation: [Creating & Deleting Branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository)

Typical branch creation flow:

1. Create a new branch in GitHub (UI or CLI)
2. Assign permissions to collaborators if required
3. Users in Nected will see the new branch (if they have GitHub access)
4. They can then switch to it and start development

## **Switching Branches**

You can switch branches directly inside Nected.

#### **To switch branches:**

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FJwBVPWYEFdW9nxeZV7Wo%2FGenerate%20Git-12.jpg?alt=media&#x26;token=3ff81bef-06b1-40a2-a4ba-a39462ba061c" alt=""><figcaption></figcaption></figure>

1. Open the branch dropdown in the bottom-left workspace sidebar
2. View the list of branches you have access to
3. Select your desired branch
4. Nected loads the content of that branch

Once the workspace finishes loading, you will see:

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FVAjHSC2wInzEx2ApO8Vd%2FGenerate%20Git-13.jpg?alt=media&#x26;token=49a111e4-6040-4b25-8c33-3f6db4478c1f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2F9JSk3NRJ3HRuTR1HHhnU%2Fimage.png?alt=media&#x26;token=35dd55c4-87f4-4e74-b735-cc548ab02438" alt=""><figcaption></figcaption></figure>

#### **Available Git configurations:**

| Setting                   | Description                                                                                    |
| ------------------------- | ---------------------------------------------------------------------------------------------- |
| **Repo Name**             | Link of the connected GitHub repository                                                        |
| Default **Branch**        | Currently active branch. Along with that, using the dropdown, you can change the active branch |
| **Personal Access Token** | You can edit the token in case the current token is expired.                                   |

Protected branches enforce Git workflows by disallowing direct changes in Nected unless changes come through GitHub merge events.

## **Deleting Branches**

Branch deletion is also handled entirely by **GitHub**.

GitHub’s documentation for deleting a branch: [Creating & Deleting Branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository)

Once a branch is deleted in GitHub:

* It is removed from the Git panel in Nected
* Users can no longer switch to it
* Any workspace tied to that branch must switch to an existing one before continuing work

> **Note:** Do not delete a branch in GitHub if you still have unpushed changes in Nected.

## **Merging Branches**

Nected does **not** merge branches.\
Branch merges happen **only in GitHub** through pull requests.

GitHub merge request documentation: [Create a PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)

The workflow is:

1. Push your changes from Nected to the selected branch
2. Open a Pull Request (PR) in GitHub
3. Reviewers approve, comment, or request changes
4. GitHub merges the branch into the target branch
5. Return to Nected and click **Pull** to apply the merged updates

This ensures all merges follow your organization’s code-review and governance policies.
