git is a version control system that is free and open source, and extremely widely used among software developers world-wide. In brief, version control systems provide a kind of "track changes" service that supports systematic backup, recovery of previous work, collaboration between people on shared documents, etc.
In CS231, we will use git to enable you and me to collaborate in the sense that you can submit various versions of your code and other documents, and I can see your work and provide feedback. On those occasions when you collaborate with a classmate on an assignment, git will also enable you to share code and maintain a single master copy of your shared code.
This document describes simple steps for the git operations you are most likely to use in this class. It is not intended to be an introduction to the concepts behind version control, git, or GitHub. For a more thorough introduction, try out one of the many git tutorials on the internet. This one, for example, looks pretty simple and helpful to me.
A git repository is essentially a folder full of subfolders and files, plus information about the history of changes that have occurred over time as files have been added, edited, moved, renamed, deleted, etc. To use a git repository, you need to clone (that is, copy) it onto your computer. You can do this using either a GUI git client or the git command-line client.
Assuming you accepted the GitHub Classroom invitation, you can now go to github.com and see the new repository (carleton-cs231-winter-2018/assignments-yourusername) in the "your repositories" section of the page. If you click on it, the resulting page shows several sets of instructions for obtaining a clone of your new repository. Some of these are more complicated than necessary for your purposes. Instead, I recommend one of the two following approaches.
The command-line git client comes pre-installed on macOS and Linux systems. It is also available on Windows 10 if you activate the Windows Subsystem for Linux.
I strongly encourage you to get familiar with the command-line operation of git, even if for day-to-day work you use a GUI git client (e.g. Option 2 below). Sometimes, you won't have access to a GUI client. Also, most tutorials and Stack Overflow discussions of git use the command line.
Whichever git client you choose, once you have cloned your repository, you should end up with a folder named "assignments-yourusername" on your computer. Initially, this folder will contain only a subfolder named ".git".
NOTE: for the remainder of this document, I will assume you're using the command-line git command. To do equivalent operations on a GUI client, check the client's documentation.
You can create new directories (e.g. "mkdir basic-authentication for your first assignment) and new files and store them as appropriate inside your repository.
When you create new folders or files, execute:
This tells git that you want it to track the new file in this repository. Note that simply adding a file to the folder isn't enough to make git keep track of the file; you also have to perform the "git add" operation.
Once you have done a little work on files in a repository, it's time to tell git that you want to save those changes in its timeline of your work. This is called committing your changes, and a single batch of changes is called a commit.
Suppose you want to include a particular file's changes in your up-coming commit. Then you need to stage the file (also known as adding the file to the staging area or adding the file to the index).
Here's what I do when I'm ready to commit.
Make your log message descriptive. Like "first draft of basic-authentication.pdf" or "repaired a bug in our exponentiation function".