Access a Git Repository Using SSH
- On the computer that you'll use to access the Git repository, generate a SSH
key pair and upload its private key to VB Studio. See Upload Your Public SSH Key for instructions. Make sure that the Git client can access
the private key on your computer.Ignore this step if you've already uploaded the SSH public key.
- Copy the Git repository’s SSH URL.
On the Git page, from the Repositories drop-down list, select the Git repository. From the Clone drop-down list, click Copy to clipboard
to copy the SSH URL:
- Open the Git client - perhaps the Git CLI.
- Navigate to the directory where you want to clone the remote Git
repository.
If the directory into which you want to clone the repository isn't empty, you'll need to create a new subdirectory and clone the repository into it. You can only perform a cloning operation into an empty directory.
- Using the Git client, either clone the project’s Git repository, or modify the remote URL of an existing clone.
-
To create a new clone of the repository using the SSH repository URL:
If you’re using the Git CLI, use the
git clone <repository-ssh-url>
command:git clone ssh://usoracle22222.john.doe%40example.com@developer.oraclecloud.com/developer1111-usoracle22222_myproject/developer1111-usoracle22222_myproject.git
If you've already cloned the Git repository to your computer using HTTPS, use the
git add remote
command to add the SSH URL of the Git repository:git remote add ssh-origin ssh://usoracle22222.john.doe%40example.com@developer.oraclecloud.com/developer1111-usoracle22222_myproject/developer1111-usoracle22222_myproject.git
-
To modify the remote URL of an existing clone that you cloned before using the HTTPS repository URL:
- Navigate to the directory of the existing HTTPS clone and run the following Git command:
git remote -v
Which should return:
origin <https-url-to-remote-repository> (fetch)
origin <https-url-to-remote-repository> (push)
Note that the origin is pointing to the HTTPS URL. This must be changed to point to the SSH URL.
If no remote repository URLs are returned when you run the
git remote -v
command, run the following command, and then skip the next step and proceed to Step c.git remote add origin <ssh-url-to-remote-repository>
- Run the following Git command:
git remote set-url origin <ssh-url-to-remote-repository>
- Run the following Git command:
git remote -v
Which should return:
origin <ssh-url-to-remote-repository> (fetch)
origin <ssh-url-to-remote-repository> (push)
Note that the origin is now using the SSH URL.
- Navigate to the directory of the existing HTTPS clone and run the following Git command:
-
- Commit the updated files to the cloned Git repository.
- Push the commit from the cloned Git repository to the hosted Git
repository:
git push origin main