After you connect to your virtual machine with vagrant ssh, you should set up Git for your repositories on your virtual machine.
Run these commands to set up your Name and Email that will be used for your Git commits. Make sure to replace “Your Name” and “your firstname.lastname@example.org” with your name and email.
git config --global user.name "Your Name" git config --global user.email "email@example.com"
You will need to setup your SSH keys in order to authenticate with GitHub from your VM.
SSH into your VM and run the following:
ssh-keygen -N "" -f ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub
The first command created a new SSH keypair. The second command displayed the public key on your screen. You should log in to GitHub and go to github.com/settings/ssh to add this SSH public key to your GitHub account. The title of your SSH keypair can be “CS 162 VM”. The key should start with “ssh-rsa” and end with “vagrant@development”.
If you already have a GitHub SSH keypair set up on your local machine, you can use your local ssh-agent to utilize your local credentials within the virtual machine via SSH agent forwarding. You can enable SSH agent forwarding in your
Vagrantfile by enabling
config.ssh.forward_agent = true. Then, you can still use
vagrant ssh to SSH into your machine. Alternatively, you can use the instructions in the previous “New GitHub Users” section.
You will have access to two private repositories in this course: a personal repository for homework, and a group repository for projects. We will publish skeleton code for homeworks in Berkeley-CS162/student0 and we will publish skeleton code for group projects in Berkeley-CS162/group0 . These two skeleton code repositories are already checked out in the home folder of your VM, inside
You will use the “Remotes” feature of Git to pull code from our skeleton repos (when we release new skeleton code) and push code to your personal and group repos (when you submit code). Your working files will be stored within the VM. Back them up by pushing to your GitHub repo. Save your work early and often. Breaking up the implementation of a large feature into several, small, clear commits is good practice, and will make it easier to determine where in your codebases’ history a bug was introduced. Communication with course staff will often involve looking at the code and commits in your repo.
The Git Remotes feature allows you to link GitHub repositories to your local Git repository. We have already set up a remote called “staff” that points to our skeleton code repos on GitHub, for both your personal and group repo. You will now add your own remote that points to your private repo so that you can submit code.
You should have received the link to your personal private GitHub repo when you registered with the autograder earlier. Add a new remote by doing the following steps in your VM:
- First, switch into your personal repository.
Then visit your personal repo on GitHub and find the SSH clone URL. It should have the form “firstname.lastname@example.org:Berkeley-CS162/…”
- Now add the remote
git remote add personal YOUR_GITHUB_CLONE_URL
- You can get information about the remote you just added
git remote -v git remote show personal
- Pull the skeleton, make a test commit and push to
git pull staff master touch test_file git add test_file git commit -m "Added a test file." git push personal master
In this course, “master” is the default Git branch that you will use to push code to the autograder. You can create and use other branches, but only the code on your master branch will be graded. You should do this test commit as soon as possible – we want to know that everyone has this basic infrastructure in place.
- Within 30 minutes, you should receive an email from the autograder. (If not, please notify the instructors via Piazza). Check cs162.org/autograder for more information.