Working with forks in SourceCraft

Forks allow you to create a personal isolated copy of another repository. A fork contains all code, commit history, and the main branch or all branches and tags of the original repository.

The main purpose of forks is to simplify the process of making changes to someone else's projects, including open source. You are free to experiment, add new features, or fix bugs, and then propose your changes back to the main project through pool requests.

For more information, see Forks .

Creating a fork

Note

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.

  1. Open the SourceCraft home page.

  2. On the Discover tab, navigate to Repositories.

  3. Select the repository you want to create a fork from.

  4. In the top-right corner, click Fork.

  5. On the page that opens, under Your new repository details, set the fork repository parameters:

    • 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: 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.

  6. Choose whether to copy only the main branch or all branches and tags of the original repository.

  7. Click Create fork.

Making changes to the original repository

  1. Clone the fork repository:

    1. Install Git.

    2. Open the SourceCraft home page.

    3. On the Home tab, navigate to Repositories and select a repository.

    4. In the top-right corner, click Clone.

    5. Depending on your connection method, copy the link for cloning the repository.

    6. In the terminal, run this command:

      git clone <link_for_cloning_repository>
      
    7. Go to your cloned repository:

      cd <repository_name>
      
  2. Create a new branch for the changes and push it to the remote fork repository:

    git checkout -b new-feature
    git push -u origin new-feature
    
  3. Make changes in the fork repository files, add them to the git index, commit, and push the changes to the remote fork repository:

    git add .
    git commit -m "added new feature"
    git push origin new-feature
    
  4. Create a pull request from the fork repository branch to the original repository branch:

    1. Go to Pull requests under Code on the fork repository page.

    2. In the top-right corner, click Create pull request.

    3. Under source in the source list, select the fork repository branch with the changes you want to add.

    4. Under target:

      • Select the original repository in the repository list.
      • In the target list, select the branch you want to add changes to.
    5. Enter a name for the pull request.

    6. Optionally, provide details of the changes in the pull request.

    7. Optionally, view the changes:

      • The 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 .

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

      • The Commits tab shows the commit history for the branch you want to pull changes from.

    8. Optionally, under Reviewers, select the pull request reviewers.

    9. 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

Pull request CI/CD processes from the fork repository branch to the original repository branch can only be started by users with the Repository developer or Repository maintainer role in the original repository. In such pull requests, automatic start of CI/CD processes is disabled.

Viewing repository forks

  1. Open the SourceCraft home page.
  2. On the Discover tab, navigate to Repositories.
  3. Select the repository whose fork you want to view.
  4. The section below the repository description will present a line with the number of forks, e.g., 3 forks. Click this line to view the list of forks.

See also