Cloning a Repository

You can clone the code repository to create a local copy on your computer, add or remove files, commit changes, and work on different branches by using Git operations.

Before you clone a code repository, you must have a code repository or a mirrored repository associated with a DevOps project.

You can use two methods to clone and use your repository: HTTPS and SSH keys.

If you have set up an OCI API signing key, you can use SSH authentication to clone your code repository. For details on how to create and manage the keys associated with a user, see the documentation on API signing keys.

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 click Code Repositories on the left-side menu.
  3. Click the Actions menu Actions menu for the repository that you want to clone and select Clone.
  4. Use one of the following methods:

    The repository is cloned and your credentials are stored for future use.

SSH Authorization

To clone the repository using an SSH key, copy the displayed URL.
Note

You must generate an SSH key pair for using SSH keys.
You must edit your SSH configuration file to specify the user and key to use for the git clone operation. The format for the host entry in your configuration file is:

Host <CodeRepositoryHost>
  User <userName>@<tenancyName>
  IdentityFile  <PathToYourSSHPrivateKey>
The SSH user is a combination of your login username and tenancy name. For example, if you are using a federated user, then your code repository's SSH user for Git is, Federation/userName@tenancyName. In the user string:
  • Federation is optional and is the federated identity provider.
  • userName is the user who signs in to the OCI Console.
  • tenancyName is the name of your tenancy, which you can find in the OCI Console.
Example, oracleidentitycloudservice/the-product-manager-user@my-tenancy
The SSH user string need not be URL encoded or escaped. For example, for a code repository in the Ashburn region, the host configuration entry is:
Host devops.scmservice.us-ashburn-1.oci.oraclecloud.com
    User the-product-manager-user@my-tenancy
    IdentityFile ~/.ssh/id_rsa

For all OCI regions, you can use a wildcard for the host, for example, Host devops.scmservice.*.oci.oraclecloud.com.

After you save your SSH configuration changes, you can clone your code repository:

On your local machine's command line, change the working directory location to where you want to clone the repository, and run the git clone command with the SSH URL that you copied.

For example, git clone ssh://devops.scmservice.us-ashburn-1.oci.oraclecloud.com/namespaces/MY-TENANCY/projects/PROJECT-NAME/repositories/REPO-NAME

HTTPS Authorization

To clone the repository by using HTTPS, copy the displayed URL.
Note

You need an auth token to clone the repository using HTTPS.

On your local machine's command line, change the working directory location to where you want to clone the repository, and run the git clone command with the HTTPS URL you copied.

For example, git clone https://devops.scmservice.us-ashburn-1.oci.oraclecloud.com/namespaces/MY-TENANCY/projects/PROJECT-NAME/repositories/REPO-NAME

You must provide your username (with tenancy, optional federated identity and username) and password (auth token) when prompted.

For a federated user, enter the username in the following format: TenancyName/Federation/UserName. For example, if you use OCI's identity provider, your login would be, Acme/oracleidentitycloudservice/alice.jones@acme.com.

If you are using OCI's direct sign-in, enter the username in the following format: TenancyName/YourUserName. For example, Acme/alice_jones. Your password is the auth token you created previously.