After you connect to the Workspace with SSH, you should set up Git for your repositories.
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@example.com” with your name and email.
git config --global user.name "Your Name" git config --global user.email "firstname.lastname@example.org"
Additionally, configure Git to merge when pulling from
git config pull.rebase false
Note: Please make sure that you are inside the cloned repo to run the command above. If you want to run the command above from the root, and make it affect all of the repos in the machine please use
git config --global pull.rebase false
You will need to setup your SSH keys in order to authenticate with GitHub from your Workspace.
SSH into your Workspace 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 Workspace”. For instructional machine users, the key will end with something like “cs162-xxx@ashby”.
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 Workspace, 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 Workspace. 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 Workspace:
- First, switch into your personal repository.
Then visit your personal repo on GitHub and find the SSH clone URL. It should have the form “email@example.com: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 main touch test_file git add test_file git commit -m "Added a test file." git push -u personal main
Note: You might encounter an issue when trying to run the
git push command that states
Unprotected Private Key File. If this is the case, you will have to update the permissions on the workspace. You can do so by running the commands below.
chmod 0700 ~ chmod 0700 ~/.ssh chmod 0600 ~/.ssh/authorized_keys
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.
- 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.