1. Creating a GitHub Account

You are about to register for an online account.

When registering, ONLY use letters and numbers (a-z A-Z 0-9) in your GitHub username and in your GitHub password.

When registering, only use letters and numbers (a-z A-Z 0-9) in your GitHub username and in your GitHub password.

When registering, only use letters and numbers (a-z A-Z 0-9) in your GitHub username and in your GitHub password.

  1. Go to http://github.com and register for an account.
  2. Save your GitHub username and password in a secure location.
  3. Verify your email account by clicking on the link in the email that was sent to you by GitHub.com.
  4. Provide your instructor with your GitHub username.

 

2. Create a GitHub Personal Access Token

GitHub now requires users to use personal access tokens rather than passwords to authenticate themselves when communicating remotely with the GitHub servers.

When you follow the instructions in the tutorial below, do the following:

In Step 6, name your token anything you like
In step 7, choose “no expiration”
In step 8, grant the token all rights by checking all of the boxes

After you’ve created your personal access token, paste the token to an accessible document file on your laptop.

To create a personal access token follow the direction in the GitHub tutorial named Creating a personal access token.

 

 

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.

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.

 

4. Pushing a File to GitHub

Prerequisite

I assume you’ve cloned our shared repository onto the Linux machine.  If you haven’t yet done so, please do so before continuing on with this tutorial.

Create README.md

Log into your Linux machine and change your working directory so that you are in the base directory of your repository.

Using an editor, create a file named README.md (if it doesn’t already exist).  Note that the filename is case sensitive.

Include at the top of the file a line of text that simply reads

# YOUR_FULL_NAME

where YOUR_FULL_NAME is replaced by your full name (spaces are allowed).

Submit Your Work

Anytime you want to copy your work (like the README.md file) to GitHub you need to do the following:

      1. Add the names of the files that you’ve modified or created to the staging list.
      2. Commit the changes to the files in the staging list to your local repository.
      3. Push your committed changes to our shared repository on GitHub.com.

Note that all of the following commands must be executed inside your repository directory.

STEP 1: Add the names of the files that you’ve modified or created to the staging list by issuing the following command.  Replace FILE_NAMES with the names of all of the files and directories (separated by spaces).

$ git add FILE_NAMES

STEP 2: Commit the changes to the files in the staging list to your local repository by issuing the following command. Include the double quotes and replace YOUR_MESSAGE with a short message describing your changes.

If you are submitting your code for review because you have a bug, add in the commit message @erimcg followed by a precise description of the issue you are trying to solve.  Note that “@erimcg can not find bug” is not sufficient.  Do not include @erimcg if you are submitting your work for a grade.

$ git commit -m "YOUR_MESSAGE"

STEP 3: Push your committed changes to our shared repository on GitHub.com by issuing the following command.

$ git push origin main

Final Step

Always check that your files were successfully copied to our shared repository on GitHub.com by logging onto GitHub.com and visually checking our shared repository.  If they’re not on GitHub, I can’t pull them.

For more information on git, please see the online reference manual: http://git-scm.com/book.