> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/code-repository/2.0/use-harness-code/manage-repositories/create-repo.md).

# Create repositories

Create repositories in Harness Code

Repositories are where your code is stored. When developers make changes to code in a Harness Code repository, those changes are tracked with version control. Harness Code fosters collaboration and governance with code reviews, approvals, status checks, and more.

You can create repositories directly in Harness Code or [import repositories](https://developer.harness.io/code-repository/2.0/use-harness-code/manage-repositories/import-repo.md) from other Git SCM providers.

### Create a repository <a href="#create-a-repository" id="create-a-repository"></a>

Create a repository directly in Harness Code:

1. In the Harness Code module, make sure you are at the [scope](https://developer.harness.io/harness-platform/use-harness-platform/platform-access-control.md#permissions-hierarchy-scopes) where you want to create the repository.

   You can create repos at the account, organization, or project scope. For example, a repo created at the account scope is available to the entire account, whereas a repo created at the project scope is limited to that project.
2. Select **Repositories**, and then select **New Repository**.
3. Enter a repository **Name** and optional **Description**.

   Repository names cannot contain the following strings:

   ```
   account.
   org.
   project.
   .git
   ```
4. Harness Code repositories are initialized with the default branch configured for the scope, or `main` if none is configured. Go to [Set the default branch for new repositories](#set-default-branch) to change the scope default. To use a different base branch name for this repository only, select the branch name and enter a new name.
5. Select your preference for visibility (**Public** or **Private**).

{% hint style="info" %}
Public repository feature is behind the feature flag `PL_ALLOW_TO_SET_PUBLIC_ACCESS`.
{% endhint %}

6. Optionally, you can add a **License**, **.gitignore**, or **README** file to your repository.
7. Select **Create Repository**.

### Set the default branch for new repositories <a href="#set-default-branch" id="set-default-branch"></a>

You can configure the default branch name that new repositories start with at the account, organization, or project scope. A repository created in a scope uses the nearest configured value, checking the scope itself first and then each parent scope up to the account. If no scope sets a value, Harness Code uses `main`.

To set the default branch for a scope:

1. In the Harness Code module, go to the scope where you want to set the default branch.
2. Go to **Manage Repositories**, and then select the **Settings** tab.
3. Enter a **Default branch**, and then save your changes.

The Settings page shows where the effective value comes from:

* **Set at this scope:** The value is configured here.
* **Inherited from** *scope*: The value comes from a parent scope. The field stays empty, and the placeholder shows the inherited branch name.
* **Not set:** No scope sets a value, so new repositories use the built-in default `main`.

To stop overriding a parent scope, clear the field or select **Reset to inherited**. A change at one scope also changes the inherited value for every scope beneath it.

When you create a repository, the base branch selector is prefilled with the effective default branch for the current scope. You can still choose another name for that repository.

### Next steps <a href="#work-with-repositories" id="work-with-repositories"></a>

After creating a repository, you can:

* [Clone your repository.](https://developer.harness.io/code-repository/2.0/use-harness-code/collaborate-and-develop/clone-repos.md)
* Create [branches](https://developer.harness.io/code-repository/2.0/use-harness-code/collaborate-and-develop/branch.md) and [tags](https://developer.harness.io/code-repository/2.0/use-harness-code/collaborate-and-develop/tag.md).
* [Commit changes](https://developer.harness.io/code-repository/2.0/use-harness-code/collaborate-and-develop/commit.md) and [open pull requests](https://developer.harness.io/code-repository/2.0/use-harness-code/pull-requests.md).
* [Configure branch rules](https://developer.harness.io/code-repository/2.0/use-harness-code/manage-repositories/rules.md) and [access control](https://developer.harness.io/code-repository/2.0/new-to-harness-code/onboarding-guide.md#manage-access).
* Use Harness Code repositories in your [Harness pipelines](https://developer.harness.io/code-repository/2.0/use-harness-code/run-pipelines/codebase-from-harness-code.md).
* Set up [triggers](https://developer.harness.io/code-repository/2.0/use-harness-code/run-pipelines/code-triggers.md) to automatically run pipelines based on activity in your Harness Code repositories.
* [Configure webhooks](https://developer.harness.io/code-repository/2.0/use-harness-code/manage-repositories/webhooks.md) to integrate your repositories with third-party applications.

{% @harness-feedback/feedback module="code-repository" pagePath="code-repository/use-harness-code/manage-repositories/create-repo" %}
