Git in CS 225
by AnonymousOverview
git
will be used throughout this semester as the version control system for MPs and labs. Specifically, we will be using git for one function:
- Distribution of provided code.
While we do not require that you learn and use good version control practices, we cannot stress enough how useful a good version control system can be when good practices are used. The following is a brief list of good version control practices:
- Always use a good commit message which describes the changes in the commit.
- Never check in broken code. (This is more important when working in groups, but still good practice.)
- Commit regularly and frequently. For example, commit when you’re done writing a function. This allows both simpler commit messages and greater confidence in the repository.
Again, the above practices are not hard and fast, nor complete, but they should help you complete your MPs and future coding projects should you use git
for them as well.
Setting up git
There are two repositories that you’ll may be interacting with as part of this course:
- Your personal course repository
- The release repository (
sp23_cs225_.release
)
In general, code will be released to sp23_cs225_.release
and you will merge it into your repository to get the initial code.
To get everything set up, there are certain things you will need to setup once the entire time you’re in the course, things you need to setup once per computer you use, and things you need to do once per MP.
Course Setup (necessary only once for the entire semester)
The first time you’re accessing the CS 225 repository this semester, you will need to have a CS 225 repository set up for you. This process is simple:
This will setup a private github for you that you can use for this course. It will be viewable by the course staff but not by other students. This will allow them to help you while not sharing your private code with anyone else.
Workspace Setup (necessary only once per computer/directory you use)
Create a clone of your repository
To setup your computer to work on an MP or a lab, you will need to clone your repository onto your comptuer.
The URL of your repository will be based on your NetID and you will need to replace NETID with your NetID.
To clone your repository, run git clone
:
git clone https://github.com/illinois-cs-coursework/sp23_cs225_NETID cs225git
…you can replace cs225git with whatever folder you want created. For example, you may want to call your folder just “cs225” or anything else.
Password entry On some systems, git (and other command line programs) will not display anything when you type your password. This is expected: type your password as normal, and then hit enter.
Finally, move into the directory you just cloned:
cd cs225git
[Optional] Store your git credentials once and for all
Run the following command so that you only have to type in your git credentials once.
git config credential.helper store
Add the release
repository as a remote
To connect to the release repository, you need to add a remote:
git remote add release https://github.com/illinois-cs-coursework/sp23_cs225_.release.git
You’re now all set to begin to work on an assignment! :)
Saving (do this often!)
Every time you want to save the work, you will need to add
, commit
, and push
your work to your git repository. This can always be done using the following commands on a command line while within your CS 225 directory:
git add -u
git commit -m "REPLACE THIS WITH YOUR COMMIT MESSAGE"
git push origin main
You should substitute "REPLACE THIS WITH YOUR COMMIT MESSAGE"
with a short message describing what you did since the commit. This will help both you and course staff understand what you did in a specific commit.
Some examples of “good” commit messages:
- “Fix the segfault in the maze destructor”
- “Implement the reverse helper function”
- “Refactor duplicate code into helper method”
Some examples of bad commit messages:
- “REPLACE THIS WITH YOUR COMMIT MESSAGE”
- “file submission”
- “commit”
- “HAAAAAAAAAAANDS”
Assignment Submission
All assignments will be submitted on PrairieLearn by uploading the files. More instructions on this will follow with the assignments.