Latest content
Explore and discover our latest tutorials
Tech Articles from your friends at Oracle and the developer community.
Oracle Cloud Infrastructure DevOps service offers a range of capabilities to developers. One of these is Code Repositories, which allows you to use Git version control to maintain your source code, with as many repositories as you need for your operations.
The first thing you need to do to start using Code Repositories is to create a Project to host your new repository. If you already have a project, you’ll just need its OCID and you can skip to the next section.
Take note of the OCID of the new project, you’ll need it in the next steps. You can just click on “Copy” next to the OCID label to copy the (rather long) string to your clipboard automatically.
Once you have a Project created, you can use the oci
command line tool to generate a repo. You can do this either in the Cloud Shell, or in you local Terminal if you have oci
installed.
To create a repository, we’ll use oci create
.
oci devops repository create --name "NAME-OF-PROJECT" --project-id "OCID_FOR_PROJECT" --repository-type HOSTED --query 'data.["http-url","ssh-url"]'
--name
is the name of the project for which you’re creating the new repo. --project-id
needs to be the OCID for the project, which you can copy from the project overview in the console. The --repository-type
should be HOSTED to create a repository you can remotely access with SSH. Adding the --query
to the end will return the HTTP and SSH urls for the new repository.
You can also retrive the SSH URL for all repositories using the list
command:
oci devops repository list --project-id "OCID_FOR_PROJECT"
You’ll see an entry for ssh-url
in the response.
Alternatively, you can grab the new ID for your repo at the time of creation and then use repository get
to retrive the urls:
repoId=$(oci devops repository create --name "NAME-OF-PROJECT" --project-id OCID_FOR_PROJECT --repository-type HOSTED --query 'data.id' | sed s'/[\[",]//g')
Then use repository get
:
oci devops repository get --repository-id $repoId --query 'data.["http-url","ssh-url"]'
mkdir [directory name].
git init
within the newly created directory.git remote add origin [ssh URL from above]
. This allows you to push and pull code from the remote repository to your local machine.example.sql
and add some sample code to it.git add [file name]
to add the new file to the repository.git commit -m [commit message]
to commit the changes to the repository.git push origin master
to push the changes to the remote repository.Your Oracle code repository is now set up and ready to use. You can continue to add and commit code changes as needed, and use the git pull
command to retrieve updates from the remote repository.