We will use GitHub for both individual and collaborative work. To get started, sign up for a personal account at GitHub. Create an account with a username that matches your UVa computing ID, for me, that would be rcg6p. In the very unlikely event that your username is unavailable, let PG know and we will find an alternative.
If you already have a github account:
- are you sure you're in the right class? This is pretty advanced for this class!
- you can create another account using a different email address to register (eg make a new gmail address if you need to)
- you can change your username following these instructions
We'll cover the basics of using Git
and GitHub below. Git
is a very powerful and very popular tool for managing software development projects, and there are many resources on-line to help with commands. You will only require a small subset of Git
's features this semester. But, the more you learn the better, since it will almost certainly benefit you in your future coding work.
The guide below is more extensive than needed for now. We'll skip to the most useful parts, following the first exercise below.
Make sure to follow this part exactly. This is a one-time setup - once you get your ssh-key installed in your GitHub account you will be able to work with GitHub all semester from you Rivanna working area.
First exercise using GitHub and GitHub Classroom
Here we will follow a step-by-step example of using GitHub/GitHub Classroom.
Setup your GitHub account
First make sure you have a GitHub account and can log in! Login using Firefox in the On Demand menu on Rivanna. You will need to paste the key you generate below into the Github browser window.
On Rivanna, make a public ssh key pair. This will make your interaction with github MUCH more convenient.
Type this at the command line on Rivanna:
ssh-keygen -t rsa -b 4096 -C <YOUR EMAIL ADDRESS> > Generating public/private rsa key pair. > Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter] > Enter passphrase (empty for no passphrase): [Press enter twice]*
* You can alternatively add a password and should do so for additional security in the real world, but it's a little easier to use a key without a password. If you trust the Rivanna sysadmins and don't publish your private key, the risk should be acceptable for this class.
- Follow the GitHub documentation to add your PUBLIC key to your account. Note: Ignore the text about using pbcopy. Instead just type this in the rivanna command line to display your public key:
>>> cat ~/.ssh/id_rsa.pub
- You can cut/paste this into the GitHub setting page (if GitHub is open in Firefox in the On Demand desktop).
In addition, due this one-time git setup for your identity (run these on the command line in Rivanna):
git config --global user.name "John Doe" git config --global user.email johndoe@example.com
That's it! The ssh-key you loaded into GitHub should be good for the rest of the semester. I hope...
NOTE: The information below is additional GitHub resources, but not required to setup your account in class 2.
Github Introduction and Documentation:
Here's a short overview of some concepts:
git
is a software tool for managing code projects, supportingcode versioning
change tracking and detailed history
GitHub is a website (one of many) that can host software projects in the cloud, providing
on-line storage
shared and private code repositories
There are many ways to use git
and GitHub. Here's an example of a basic development process that you might follow for a new project:
Start by creating a code repository on GitHub (the host of your remote repository).
Clone your (remote) repository from GitHub to your local machine. On your local machine the repository appears as a directory.
Write some code!
Add any new or modified code to your local repository (using
git add
command). This prepares the code to be included into you local repository.Commit your changes to your local repo. Make sure to use the "-m" option and include a comment about the commit in quotes. If you forget "-m" you will end up in the Vim editor. How to get out of Vim.
Push your changes to the remote repo on GitHub. This provides a backup in the cloud that you can access from anywhere and also makes it easy to collaborate with other coders. You and those you trust to write to the repo can all push changes to the cloud and pull the contributions of others into you local working area using simple
git
commands.
Here are a few links to videos introducing git
and GitHub(classroom). Browse these and other resources as your curiosity guides you (after completing the in-class work). But, if you have questions just post them and you'll develop your basic git skills quickly.
A brief overview of git. A very quick read with friendly drawings.
Git Tutorial for Beginners: Command-Line Fundamentals 30 mins
Git Tutorial for Beginners - Git & GitHub Fundamentals In Depth 43 mins
How to submit an assignment to Github Classroom (with starter code) (note: you should get the ssh link for cloning, not the https link shown in the video)
There are MANY cheat sheets for git
, for example, see
Because we are using GitHub Classroom, the projects you work on here will be upgraded with additional features compared to the free accounts. The process we use for starting projects will be slightly modified:
First you will receive a link to a starter repository provided through the classroom.
Each student will make a copy of the repository and clone it to your area on Rivanna.
Generally these will be set as private repositories - no other students will see your repository.
Submissions of your work will simply be a matter of pushing your final code and any material discussing your results to GitHub.