Overview

Skill Level: Beginner

Learn how to create and connect to a Git repo on one of IBM Cloud Git Repos and Issue Tracking servers.

Ingredients

  • Install the following on your machine:
  • Create an IBM Cloud account, if you don't have one.

Step-by-step

  1. Connect to one of IBM Cloud Git Repos and Issue Tracking servers to create a repo

    Skip this step, if you aleady have an existing repo that you want to use.

    Connect to one of the IBM Cloud Git Repos and Issue Tracking servers listed in this page: (I chose “us-south.git.cloud.ibm.com” for this recipe)

    https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-git_working#verifying-host-key-fingerprints

    recipe02-step01-0001

    Click “New project” and complete the information below, then click “Create project” button:

    recipe02-step01-0002

     

    Observe the two messages at the header of the page indicating that you need to configure SSH and create a personal access token. That is what you are going to do in the following two steps.

    recipe02-step01-0003

     

    Copy the repo URL from the “Clone” for the next step. NOTE: You will just need the first part of the URL without the repo name which should look like this: https://us-south.git.cloud.ibm.com:<yourusername>

    recipe02-step01-0004

  2. Generate an SSH public key on your machine to be used to access the repo on IBM Cloud

    Execute the following command from the command line and press enter when prompted for input to accept defaults.

    recipe02-step02-0001

    Copy the content of the one-line in the id_ed25519.pub file generated for the next step. Make sure you include the last part of the line that has your username.

  3. Add the SSH public key to the repo on IBM Cloud

    recipe02-step03-0001

    recipe02-step03-0002

     

    Paste the content of the id_ed25519.pub file into the “Key” box and press “Add key”.

    recipe02-step03-0003

  4. Generate a personal access token on IBM Cloud so that you can commit code changes from your local machine later

    recipe02-step04-0001

     

    You just need to have “write_repository” scope, but you can select all of them and click “Create personal access token”.

    recipe02-step04-0002

    Copy your personal access token for the next step.

    recipe02-step04-0003

     

  5. Clone the repo locally and make your first push

    Execute the following commands from the command line. You’d better create a new directory for your new local repo and run the commands from there. When you get challenged for a user name and password use your git user name and the personal access token (you copied from the previous step) as the password.

    recipe02-step05-0001

    Observe the file you created on your local machine being listed on the repo online.

    recipe02-step05-0002

  6. [Optional] Make an update to a file locally and commit the change to IBM Cloud

    Execute the following command from the command line. This is to update the same file you created and push it to the repo.

    recipe02-step06-0001

    Observe the updated content of the on the online repo.

    recipe02-step06-0002

Join The Discussion