Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Virtual machine configuration

Table of contents

  1. Git name and email
  2. SSH keys
    1. New GitHub users
    2. Experienced GitHub users
  3. Repositories

After you connect to your virtual machine with vagrant ssh, you should set up Git for your repositories on your virtual machine.

Git name and email

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 email@berkeley.edu” with your name and email.

git config --global user.name "Your Name"
git config --global user.email "your_email@berkeley.edu"

Additionally, configure Git to merge when pulling from staff:

git config pull.rebase false

SSH keys

You will need to setup your SSH keys in order to authenticate with GitHub from your VM.

New GitHub users

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”. For VirtualBox users, the key should start with “ssh-rsa” and end with “vagrant@development”. For instructional machine users, the key will end with something like “cs162-xxx@ashby”.

Experienced GitHub users

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.

Repositories

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 ~/code/personal and ~/code/group.

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:

  1. First, switch into your personal repository.
    cd ~/code/personal
    
  2. Then visit your personal repo on GitHub and find the SSH clone URL. It should have the form “git@github.com:Berkeley-CS162/…”

  3. Now add the remote
    git remote add personal YOUR_GITHUB_CLONE_URL
    
  4. You can get information about the remote you just added
    git remote -v
    git remote show personal
    
  5. Pull the skeleton, make a test commit and push to personal main
    git pull staff main
    touch test_file
    git add test_file
    git commit -m "Added a test file."
    git push -u personal main
    

    In this course, “main” 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 “main” 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.

  6. Within 30 minutes, you should receive an email from the autograder. (If not, please notify the instructors via Ed). Check cs162.org/autograder for more information.