Managing Your Repository

Dear Computer

Howtos

Managing Your Repository

All your code for this semester goes in a single Git repository that your instructor has already made for you on GitHub. We use version control—and Git and GitHub, in particular—for several reasons:

Every time you work on a lab, reading exercise, or project, you should put the code you write in this repository. After each work session, you should commit and push this code to GitHub—no matter its state of completion.

Git is complex software designed for a complex task. However, most issues with version control arise when multiple people are contributing to a repository. Since you are the only software developer contributing to your repository, you won't have to deal with many of these issues.

To get your Git repository up and running, complete the following tasks.

Make Accounts

Your repository has already been made and is waiting for you. Follow these steps to be added to it as a contributor:

Visit this course's Canvas page.
Follow the instructions in Join GitHub Organization.

Install Software

Follow these steps to install the software that you'll use to write code and synchronize it with your GitHub repository:

Install Git. Modern development environments provide their own interface around Git, but they still expect it to be installed separately. You may have Git installed already. Check by trying to run git in a terminal.
Install Visual Studio Code. We favor Visual Studio Code in this course. If you prefer some other development environment, that's fine. Just make sure you know how to navigate its Git interface or use Git at the command-line. These instructions assume you are using Visual Studio Code.

Clone Your Repository

Your repository is currently only a remote repository. Follow these steps to mirror or clone it onto your local machine:

Open Visual Studio Code, choose View / Command Palette from the menu, and enter Git: Clone.
Paste in your repository's URL at the prompt.
Select the folder on your computer in which you want your repository to be stored.
Authenticate with GitHub.

Cloning needs to be performed only once per computer that you use.

Daily Workflow

Each work session involves just these few steps, which will quickly become second nature:

Open your local repository's top-level project directory. Don't open subdirectories, as Visual Studio Code will not sense that the project is managed by Git. Immediately after cloning, the project will be empty.
Make your changes by adding or editing files and folders. In this initial session, add a new README.md file with a short blurb describing your hopes and dreams for this repository.
Choose View / Source Control from the menu.
Hover over Changes and click the plus button to add all changes. Ensure that both new files and tracked files with edits are added. Make a habit of committing all changes all the time. However, some files—like executables, other files that can be derived from the source, and large binary files—don't belong in version control. They waste space and time and will earn you scorn from teammates. Right-click on any such file and select Add to .gitignore.
Enter in the message box a short description of the changes.
There are two actions left before your changes are truly saved: committing (which earmarks these changes as a new revision in your local repository only) and pushing (which sends the revision up to GitHub). Perform both of these at once by clicking the down arrow to the right of the Commit button and choosing Commit and Push. If you accidentally hit Commit only, then click on the ellipsis button on the top-right of the panel and choose Push.
Verify that your changes made it to GitHub by visiting your repository in a web browser. If you can't see your changes there, then neither can your instructor.

You are strongly discouraged from uploading files directly to your repository using GitHub's website. Use this opportunity to learn how to use version control properly.

If you use more than one computer, you'll want to start each work session by pulling down any changes committed from other computers.

Curses Recipes →