W1007 GitHub

From Coder Merlin
GitHub Zombie Octocat



While using git locally is a wonderful way to track our revisions and enable us to rollback to previous versions, in order to take full advantage of git we'll use GitHub. GitHub is a service where we can replicate (copy) our repository and collaborate with others.

A GitHub Account[edit]

Your guide will set up a repository for your use for this assignment. Be sure to follow the instructions carefully. In order to participate, you'll need a GitHub account. GitHub accounts are free to create.

  1. Go to https://github.com
  2. Click on the GitHub-Sign up Button.png button at the top, right-hand side of the page
  3. On the next page ("Set up your account") there will be a short form:
    1. Create a unique (and appropriate) username
    2. Provide an accessible email address, as directed by your guide
    3. Provide a password
    4. You may receive a small puzzle to solve; if so, solve the puzzle
    5. Click on the "Create Account" button GitHub-Create Account Button.png
  4. On the next page you may have a brief survey. At the bottom, click the "Complete Setup" button GitHub-Complete Setup.png
  5. You'll receive an email to the address you specified.
    1. Check your email client and find the email from GitHub
    2. Click the GitHub-Confirm Email Button.png button


In order to use these commands with a remote repository, it's best to cache your credentials. On the command line, execute:

jane-williams@codermerlin:~$ git config --global credential.helper 'store --file ~/.git-credentials'
jane-williams@codermerlin:~$ git config --global credential.useHttpPath true

In order to squelch the warning that occurs while pushing, execute:

jane-williams@codermerlin:~$ git config --global push.default matching

Note: These commands, if successful, will complete silently.


Your guide will create a GitHub assignment for you. You'll receive an email with an invitation link.

  1. Sign in to GitHub using the correct account BEFORE clicking on the link
  2. Click on the link

Helpful Hint

Your guide will create assignments for you which are "Private"; they'll only be visible to you (or your group for group assignments) and your guide. If you create any repositories on your own, be sure you select the correct setting.

Joining the Classroom Roster[edit]

The first time that you click on an assignment you'll be asked to join the classroom roster. You'll see a message similar to: "Join the classroom roster: Your teacher has configured this classroom to pair GitHub accounts with identifiers."

  1. Click on your identifier. (Do NOT skip this step.)
  2. The next page will present you with an GitHub-Acccept This Assignment Button.png. Click the button.
  3. You'll may see a progress bar (or two). Be patient as your assignment is prepared. When the assignment is ready, you'll see the message: "You are ready to go!"
  4. They'll be a link at the very bottom of the page, immediately after the text "Your assignment has been created here:" Click on that link. You'll need this link in a subsequent step in this experience.

Helpful Hint
The link that you just clicked on is the link to your personal repository for the assignment. It might be something that you'd like to bookmark.

First GitHub Assignment[edit]

Your first GitHub assignment will be to sync all of your journals with GitHub. In order to do so, you'll need to specify a GitHub URL as your "remote" for your existing git repository.

Enter your Journals directory:

john-williams@codermerlin:~$ cd ~/Journals

Remember that you've already added all of these files to your local git repository. You can easily verify this by checking the status.

john-williams@codermerlin:~/Journals$ git status

You should see something similar to:

On branch master
nothing to commit, working tree clean

Let's add the remote. To do so, we'll need the URL from the above assignment. It will be something similar to:
Be sure to use your own url, which will be unique to you.

john-williams@codermerlin:~/Journals$ git remote add origin https://github.com/.../2020-journals-JohnWilliams.git

Then, we can push our local commits to the remote server:

john-williams@codermerlin:~/Journals$ git push -u origin master

You'll then be promoted to enter your username and password. Remember to use your GitHub username and password. After the push is completed, go back to the browser and refresh the page.

Workflow Overview[edit]


The workflow when using a remote repository is very similar to that using only a local repository, with the exception of push and pull.

  1. add the files to the staging area
  2. commit the files to the repository
  3. push the local repository to the remote

The most significant difference is that we'll need to keep in mind that others may also be working on the remote repository, so we'll need to sync their remote changes with our local repository. The best practice is to perform a pull prior to beginning work in the working directory.


As you progress through your work, whether it be code or prose, you'll accumulate more and more commits each with their own version of a particular file. There'll be times when you'll need to mark a specific commit. For example, you may want that commit to be reviewed by your editor or by quality assurance personnel. Git is able to mark specific points in the repository as being important. This process is called tagging and the mark itself is called a tag. It's important to note that the entire repository at a given point in time is tagged, not a particular file or group of files.

Tagging Locally[edit]

A tag can be placed on the repository with the following command, replacing tagName with the actual name of the tag.

john-williams@codermerlin:~$  git tag tagName

For example:

john-williams@codermerlin:~$  git tag E1399.Outline

Pushing a Specific Tag to a Remote[edit]

A tag may be pushed to a remote repository with the following command:

john-williams@codermerlin:~$  git push origin tagName

For example:

john-williams@codermerlin:~$  git push origin E1399.Outline


Pushing a tag will include all required objects for that tag, but will NOT include any other references. For example, it will not include your commits. Therefore, it is vital that you first push your commits by executing:

john-williams@codermerlin:~$  git push

and then push any desired tags.

Deleting a Tag Locally[edit]

A tag may be deleted locally with the following command, replacing tagName with the actual name of the tag.

john-williams@codermerlin:~$  git tag --delete tagName

Deleting a Tag from a Remote[edit]

A tag may be deleted from a remote with the following command, replacing tagName with the actual name of the tag.

john-williams@codermerlin:~$  git push --delete origin tagName

Best Practices[edit]

Coming Soon
  • Include only essential files required to reproduce project (e.g. source files)
  • Avoid unnecessary files (e.g. compiled products and temporary files)
  • How to use .gitignore

Key Concepts[edit]

Key Concepts
  • GitHub is a service where we can replicate (copy) our repository and collaborate with others
  • GitHub serves as a remote repository
  • The workflow when using a remote repository is very similar to that using only a local repository except that additional commands are required
    • push will push the files from the local repository to the remote repository
    • pull will pull the files from the remote repository to the local repository (and working directory)
    • tag will mark a specific commit as 'special'
    • push origin <tag> will push the specified tag from the local repository to the remote repository


  • Push all of the journals in the Journals directory to GitHub and be sure to continue to push all new/modified journals as well. Note that this applies to essays and excursions as well.
  • Journals and essays should be stored in your "Journals" directory and pushed to your "Journals" repository.
  • Exercises and excursions should be stored in your "Experiences" directory and pushed to your "Experiences" repository.
  • Your final version of any exercise must be tagged as <ExerciseName>.Final. For example, for J1006, the file will be named J1006.txt (because it is a text file) and the final version should be tagged J1006.Final


Designed with pride in Silicon Valley, CA, USA