Git is a version control system. It allows you to track and share changes to your code. Instead of having a single copy of your code, you'll keep a working copy that you edit, and send checkpoints of your work to a code repository. In this class, you'll be using Git to submit your programming assignments by checking it into a repository that the gradebot can also check out. This document will help you get started with checking out and checking in project code with Git for this class. You'll learn about other features of Git in discussion sections or by reading the resources linked at the bottom of this page.
To identify yourself to the repository to check out assignments and
check them back in, you will need a private key. After you register, the gradebot will mail you the private key in a file named id_rsa
. Keep this file safe with appropriate permission if you are on a shared machine. Anyone with access to this file can also access your code repository and read or make changes to your submission.
In a terminal, copy the key file into
your ~/.ssh/
directory. The following instructions assume that you don't already have a private key.
mkdir ~/.ssh
.cp id_rsa ~/.ssh/
chmod -R go= ~/.ssh
$ mkdir ~/.ssh $ mv id_rsa ~/.ssh/ $ chmod -R go= ~/.ssh $ ls -l ~/.ssh -rw------- 1 chen chen 1743 2010-06-17 18:07 id_rsa
You can check out from a repository using
git clone
, followed by the repository name. For example,
to check out the first assignment, you would run git clone
metastasis@gradebot.org:user/username/courseid/1
, where username is your school email ID. You'll now find a
directory called 1
that you can work on. If
you get a prompt asking for your password, you made an error
during set up and you should recheck your steps.
$ git clone metastasis@gradebot.org:user/chen/1/1 Cloning into 1... Initialized empty Git repository in /home/gradebot/live/gitolite/repositories/user/chen/1/1.git/ warning: You appear to have cloned an empty repository. $
If you get a warning about empty repository, ignore it, because your repository is indeed empty initially.
After you're done editing and ready to submit, you'll need to commit and push your code back to the server. You'll do that with the following commands.
git clone
created.
git add filename
for each new file. git commit -a
. It will
prompt you for a comment associated with this check in. You'll want to
write a meaningful comments to help you remember what you've changed
since the last check in.git push origin master
. This will send your changes to the
remote repository, where the gradebot will grade it.You can check in as often as you like. We'll only grade your most recent check in. You may wish to check in after any incremental progress, especially when working on the programming assignments.
To learn more about Git, you can visit the following websites.
Forget Password
function on the front page.
Recreate key
function.