3. Cloning a Repository

Here we assume that you have set up Git, created a GitHub account, and created a GitHub personal access token.  In addition, we assume your instructor has created a repository on GitHub and shared it with you.

Contents

View Our Shared Repo on GitHub

To view our shared repository, log onto GitHub, and navigate to your profile. You can find your profile page by clicking on the user icon in the upper right corner of the page and selecting Your profile in the drop-down menu.

On your profile page, in the bottom left side of the page, click on the icon listed under Organizations.

On the organization page you should see a link to your repository.  Write down the organization name and the repository name.  You’ll need to use them below.

Clone Our Shared Repository

To clone our shared GitHub repository onto the Linux server, execute the following command while replacing

    • USER_NAME with your GitHub username
    • ACCESS_TOKEN with your GitHub personal access token
    • REPO_NAME with our GitHub repository name (which is your BC username)

Note:  the following command is typed on a single line.

$ git clone https://USER_NAME:ACCESS_TOKEN@github.com/BC-CSCI/REPO_NAME

Git will create a new folder with the same name as the repository name in your working directory and copy over all the files that are in the GitHub repository.

Type pwd on the command line to see your current working directory.  You should see a path similar to the one below except rmcgregor will be replaced with your Bridgewater username.  This is your home directory.

/home/rmcgregor

Now, list the contents in your current working directory using the ls command to see the repository that was just created.  You should see a directory with the name of your repository.  That directory IS your repository.  You’ll put all of your work for this course in that repository.

Change directory into the repository by issuing the following command, replacing repository-name with the name of your repository.

$ cd repository-name

Type pwd again on the command line.  You should see a path similar to the following, except instead of rmcgregor you should see your Bridgewater username twice.

/home/rmcgregor/rmcgregor

Keep Your Repository Organized

The work you do will eventually end up in the repository on GitHub where your instructor can review your work.  To get credit for your work, please organize your work as instructed by your instructor.

    • If your instructor asks you to create a directory with a specific name, please name it exactly as specified. 
    • If he asks you to give a file a specific name, give it the name exactly as specifies. 
    • Directory and file names are case-sensitive on Linux.

 

© 2021 – 2022, Eric. All rights reserved.