---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/fork-work.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/fork-work.md
  - href: en/sourcecraft/operations/fork-work.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt

# Working with forks in SourceCraft

<!-- source: en/_includes/sourcecraft/fork-description.md -->
_Forks_ allow you to create a personal isolated copy of another [repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#repos). A fork contains all code, commit history, and the main branch or all branches and tags of the original repository.

Forks simplify the process of making changes in someone else's projects, including open source ones. You are free to experiment, add new features, or fix bugs, and then propose your edits to the main project as [pull requests](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr).
<!-- endsource: en/_includes/sourcecraft/fork-description.md -->

For more information, see [Forks ![image](../../_assets/console-icons/code-fork.svg)](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#forks).

## Creating a fork {#create-fork}

<!-- source: en/_includes/sourcecraft/fork-access.md -->
{% note info %}

To create a fork, you need the permissions to read the original repository. To create a fork from an existing one, you need permissions to read all the repositories in the chain. For more information, see [Access management in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/index.md).

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/fork-access.md -->

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/planet-earth.svg) **Discover** tab, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select the repository you want to create a fork from.
1. In the top-right corner, click ![image](../../_assets/console-icons/code-fork.svg) **Fork**.
1. On the page that opens, under **Your new repository details**, set the fork repository parameters:

    <!-- source: en/_includes/sourcecraft/repo-fork-create-details.md -->
    * In the **Owner** field, select the organization to create the repository in.
    * In the **Name** field, specify a name for the repository. 
           
      The name must be unique within the organization. The name may contain the following [ASCII characters](https://ru.wikipedia.org/wiki/ASCII): lowercase and uppercase Latin letters, numbers, commas, hyphens, and underscores.

      The address to access the repository at is displayed below the name.

    * Optionally, in the **Description** field, enter a description for the repository.
    <!-- endsource: en/_includes/sourcecraft/repo-fork-create-details.md -->

1. Choose whether to copy only the main branch or all branches and tags of the original repository.
1. Click **Create fork**.

## Making changes to the original repository {#pr-to-origin}

1. Clone the fork repository:

    <!-- source: en/_includes/sourcecraft/clone-repo-workflow.md -->
    1. [Install Git](https://git-scm.com/downloads).
    1. Open the SourceCraft [home page](https://sourcecraft.dev).
    1. On the ![image](../../_assets/console-icons/house.svg) **Home** tab, under ![image](../../_assets/console-icons/layout-tabs.svg) **Your craftspace**, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories** and select your repository.

        Also, you can open any public repository.

    1. In the top-right corner of the repository page, click ![image](../../_assets/console-icons/chevron-down-wide.svg) **Clone**.
    1. From the **HTTPS** or **SSH** field, copy the ![image](../../_assets/console-icons/copy.svg) repository cloning link.

        Depending on the cloning connection protocol, different domains are used:

        #|
        || **Protocol** | **Domain** | **Cloning link** ||
        || HTTPS | `git.sourcecraft.dev` | `https://git@git.sourcecraft.dev/<organization_slug>/<repository_slug>.git` ||
        || SSH | `ssh.sourcecraft.dev` | `ssh://ssh.sourcecraft.dev/<organization_slug>/<repository_slug>.git` ||
        |#

    1. In the terminal, run this command:

        ```bash
        git clone <link_for_cloning_repository>
        ```

        {% cut "Example of a command for cloning a repository with SourceCraft documentation" %}

        ```bash
        git clone https://git@git.sourcecraft.dev/sourcecraft/documentation.git
        ```

        {% endcut %}

        <!-- source: en/_includes/sourcecraft/private-repo-clone-note.md -->
        {% note warning %}

        To clone a [private or internal repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#repos), authenticate with a [personal access token (PAT)](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/pat.md) or [SSH key](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/ssh.md).

        {% endnote %}
        <!-- endsource: en/_includes/sourcecraft/private-repo-clone-note.md -->

    1. Go to your cloned repository:
        
        ```bash
        cd <repository_name>
        ```
    <!-- endsource: en/_includes/sourcecraft/clone-repo-workflow.md -->

1. Create a new branch for the changes and push it to the remote fork repository:

    ```bash
    git checkout -b new-feature
    git push -u origin new-feature
    ```

1. Make changes in the fork repository files, add them to the `git` index, commit, and push the changes to the remote fork repository:

    ```bash
    git add .
    git commit -m "added new feature"
    git push origin new-feature
    ```

1. Create a [pull request](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr) from the fork repository branch to the original repository branch:
    1. Go to ![image](../../_assets/console-icons/code-pull-request.svg) **Pull requests** under ![image](../../_assets/console-icons/code.svg) **Code** on the fork repository page.
    1. In the top-right corner, click **Create pull request**.
    1. Under **source** in the **source** list, select the fork repository branch with the changes you want to add.
    1. Under **target**:
        * Select the original repository in the **repository** list.
        * In the **target** list, select the branch you want to add changes to.
    1. Enter a name for your pull request.
    1. Optionally, provide details of the changes you are making in the pull request.
    1. Optionally, view the changes:
        * The ![image](../../_assets/console-icons/file-code.svg) **Files changed** tab gives a list of modified files and the changes made to them in `.diff` format.

          To view the changes in _before/after_ format, click ![image](../../_assets/console-icons/layout-columns.svg).

          To view all files in the branch you want to pull changes from, click **Full tree**.

        * The ![image](../../_assets/console-icons/code-commit-horizontal.svg) **Commits** tab shows the commit history for the branch you want to pull changes from.
    1. Optionally, under **Reviewers**, select the pull request reviewers.
    1. Click **Publish pull request**.

        You can also save your pull request as a draft to complete it later instead of creating it right away. To do this, click **Save as draft**.

{% note info %}

<!-- source: en/_includes/sourcecraft/fork-ci-restriction.md -->
Pull request [CI/CD processes](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md) from the fork repository branch to the original repository branch can only be started by users with the `Repository developer` [role](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/index.md#src-repositories-developer) or `Repository maintainer` [role](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/index.md#src-repositories-maintainer) in the original repository. In such pull requests, automatic start of CI/CD processes is disabled.
<!-- endsource: en/_includes/sourcecraft/fork-ci-restriction.md -->

{% endnote %}

## Viewing repository forks {#get-forks}

1. Open the SourceCraft [home page](https://sourcecraft.dev).
1. On the ![image](../../_assets/console-icons/planet-earth.svg) **Discover** tab, navigate to ![image](../../_assets/console-icons/archive.svg) **Repositories**.
1. Select the repository whose fork you want to view.
1. The section below the repository description will present a line with the number of forks, e.g., ![image](../../_assets/console-icons/code-fork.svg) **3 forks**. Click this line to view the list of forks.

#### Useful links {#see-also}

* [SourceCraft resource relationships](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md)
* [Creating a repository in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-create.md)
* [Importing or mirroring a repository in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/migration.md)
* [Creating a pull request in a SourceCraft repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/pr-create.md)
