Forking a Code Repository

You can fork the code repository to create a copy in any DevOps project in the same tenancy, add or remove files, commit changes, and work on different branches by using Git operations.

Before you fork a code repository, you must have a code repository.

For accessing DevOps using the Oracle Cloud Console, REST API, and CLI, see Accessing DevOps.

    1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
    2. Select a project and from the left-side menu, click Code Repositories.
    3. Select a code repository, and then click the Create Fork button on the Repository details page.
    4. Select a compartment for the forked repository.
    5. Select a DevOps project.
    6. Enter a unique name for the repository.
    7. Click Create.

    The forked repository details are displayed that includes link to the parent repository and the default branch. The forked repository can be forked again.

    You can perform the following actions on the forked repository:

    • Synchronize the forked repository.
    • Create pull request.
    • Clone the repository.
    • Compare parent and forked repository: To compare file changes and commit changes between any two branches belonging to the same repository or the parent repository, click Compare. Choose a source and target repository. Select the associated source and target branch to compare. The highlighted file changes and commit details are displayed. The changes can be viewed inline or side-by-side.
  • To create a forked repository, run the create command:

    oci devops repository create

    Required parameters are:

    • --name
    • --project-id
    • --repository-type FORKED
    • --parent-repository-id
    • -repository-id
    • source-repository-id

    To compare fork branch with the parent branch run the get-commit-diff command:

    oci devops repository get-commit-diff

    Required parameters are:

    • -repository-id
    • --target-version
    • --target-repository-id.

    To check fork branch sync status run the list-fork-sync-statuses command:

    oci devops repository list-fork-sync-statuses

    Required parameters are:

    • --branch-name-query-param
    • --repository-id

    To create pull request from fork repository to parent repository run the create command:

    oci devops pull-request create

    Required parameters are:

    • --display-name
    • --repository-id
    • --source-branch
    • --destination-branch
    • --reviewers
    • --source-repository-id

    To get all the commands for repository:

    oci devops repository -h
  • To fork a code repository, use the CreateRepository operation.