Git is a distributed version control system. The revisions are saved locally and the entire repository can be synced with other repositories.
To learn about Git,
man gittutorial
is a good place to start, and The Git User's Manual can give all the information needed (and there are more than a handful of other tutorials on the web).
Github is a centralized service for hosting git repositories.
The school has its own instance of github at https://github.cs.huji.ac.il. All of the school's students and staff have an account there (using the normal unix login+password). This service is accessible world-wide, which allows to work on code at home and sync it to the cs network without the need for ftp or scp.
There are a couple of differences between the public github instance and CSE instance:
A one time procedure is needed to set up the git environment to work properly (such as setting up credential and setting the user data):
It is best to run the
github-setup
command, and follow the instructions:
<5|0>zivben@dali:~% github-setup Using existing public key for data Please go to
https://github.cs.huji.ac.il/settings/tokens
, with your CS username and password, and click "
Generate new token
" with: Note:
setup
Check:
admin:public_key
Click
"Generate token"
Once you log in to the HUJI github page, click the "generate new token" button:
Once there, recall the instructions from the command line tool and fill in "setup" as the note, and tick the "admin:public_key" box like so:
Now scroll down and click the green "generate token" button. You will be transferred back to the tokens screen, but this time your new token will appear:
Copy the token string and paste it back to the command line prompt:
<6|1>zivben@dali:~% github-setup Using existing public key for data Please go to
https://github.cs.huji.ac.il/settings/tokens
, with your CS username and password, and click "Generate new token" with: Note: setup Check: admin:public_key Click "Generate token"
And paste the token here: 41893856a42ef0db5dae9db35fd3faeb6e66a3f6
Adding key to github
~/.ssh/config already has a github.cs.huji.ac.il configuration
You can now delete the token (from http://github.cs.huji.ac.il/settings/tokens )
This will set up the local git configuration and the ssh id in the github so that a password won't be needed for each sync.
The standard github instructions should work. In addition, to have the git submit command working, the following command needs to be executed:
git config --global alias.submit "push origin master:master master:submit"
Our github currently only knows of the cs mail addresses. As such, it is important to commit using the cs.huji mail address. To set this up:
git config --global user.name "<My Name>" git config --global user.email "<login>@cs.huji.ac.il"
For efficient use with the credentials it is recommended to connect via SSH.
Other github operations can be found in the github help
Github pages are available. See GitHub Pages for more details.
Github can be used for working on exercises for CS courses. Each exercise needs to be specifically designated as a GIT type by the course's staff for this to work.
Once an exercise has been set for git usage, a repository will be created for each student in the github in the form:
<course>-<year>/<exercise>-<login>
e.g.
intro2cs-2016/ex1-penguin7
The <year> is the year at the start of the academic year. Even for second semester courses which technically starts at the next civil year.
This repository is opened for the student for read/write (pull/push). And it is opened for the course's staff as read only (pull). If working in pairs, it will be opened for the paired student as well.
Normal submission will be disabled for git type assignments, and any attempt to submit through moodle will result in moodle taking github's last submission.
First make sure to set up the git environment (this is a one time procedure for all courses):
github-setup
All the examples below are using these example parameters (as above):
Once an exercise is defined by the course, you can access it through the web
http://github.cs.huji.ac.il/intro2cs-2016/ex1-penguin7
To clone the repository and start working on it:
git clone git@github.cs.huji.ac.il:intro2cs-2016/ex1-penguin7.git
To add files to the repository (e.g. some-file.py):
git add some-file.py
After working on the exercise, to commit a well defined set of changes:
git commit -a -m "commit message"
The "commit message" should be a short (or multi-lined long) description of this commit.
To push the changes to github:
git push
This will make the changes available in github, but not considered as submitted yet
To submit the changes:
git submit
To see the local status of the git repository (local changes):
git status
To undo changes to 'afile.py' and restore from the last commit:
git checkout -- afile.py
Once the changes have been submitted, the submission will be processed and a mail will be sent once the process is completed (shouldn't be more than a few minutes, using the "bodek" system).
Important: The submission is through a special git protected branch "submit". Any advance git operations (rebase, reset --hard, merge, etc.) which might break the sync between the master branch and the submit branch, will require re-merging of them in order to work again.
If you want to use github for assignments, please contact the system in advance, as opening the github's organization for the course needs a one time manual operation (per course per semester, not per assignment).
Some general details regarding using github for submissions: