Github Guide

What is GitHub?

GitHub is a version control system that is built on Git. It allows one to store code and make changes to an online repository. This allows one to easily change and update code as well as collaborate with others by sharing a common repository. We will be using GitHub Classroom to distribute all of the stencil code for assignments using a link on the course website, but let’s learn a little more about GitHub and Git.

Why GitHub?

  • Store your code and files on an online repository so you won’t lose your code.
  • If you commit (save) and push your code often:
    • If your computer crashes or you make a mistake, you can revert to an earlier version of your code and keep working
    • You can create a record of changes and always check out a previous version
  • Allows for easy collaboration. People can work on the same repository and update/change code on separate machines.
  • You can sign up for an account here and get the GitHub Student Pack with your Brown Email for more tools and

Some Essential Commands of Git

Git is the basis of GitHub and is a version control system you can use right from the command line, you can learn more about it on their website!

  1. Download the latest version of Git here.
  2. Check out the installation guide here.
  3. There is also a great cheat sheet of git commands that GitHub provides here.

Below are some common git commands to get you started!

  • git clone [URL-or-path-to-repo] - Retrieve an entire repository from a hosted location via URL to your local machine
  • git status - Display the state of the current repository. Use this to see your tracked files, untracked files and changes.
  • git add [file] - Add the given file to the repository. Use this when you create a new file and want to include it in a commit. Alternatively, include `[-a]`` to add all files from your local repo
  • git commit -m [some message] - Commit your code to finalize and save changes to your current branch and repo on your local machine.
    Include [-a] to automatically add changed files that git is already tracking and [-m “[some message]”] to include a message about the commit (otherwise you will be kicked to an editor in which to type out your message).
  • git push - Push whatever commits you have made locally to the repository you cloned from to save your changes to the online repo. (You might have to pull first to sync with the remote repository)
  • git pull - Pull any changes from the remote repository you cloned from.

Github Desktop

If you prefer GUIs we recommend using GitHub Desktop, this gives you a great visual way of interacting with GitHub. It allows you to better visualize your code changes when you commit and push, and helps prevent committing files that you don't want to be stored in your repo.

You can download Github Desktop for your platform here, and follow the setup guide here.

Github Classroom

When you click the Github Classroom link for a programming assignment and accept the assignment, it will bring you to a repository for you to use for that assignment. If you click the green Code button in the top right corner, you should see something like the following:

You can then either use Github Desktop to clone the repository, your use the first URL and type git clone [URL].

Note: You may need to create a GitHub Personal Access Token to clone using the CLI.

Select a repo