Github

From CsWiki
Jump to: navigation, search

Git and Github

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.

Github at CS

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.

Initial setup

A one time procedure is needed to set up the git environment to work properly:

Inside the cs network

It is best to run the

github-setup

command. 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.

From home

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:submit'


Other github operations can be found in the github help

Github for exercise submission

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

This repository is opened for the student for read/write (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.

For students

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):

  • course - intro2cs
  • year - 2016
  • exercise - ex1
  • user - penguin7

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).

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.

For teachers

If you want to use github for assignment, 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:

  • The submission is to a special protected branch "submit", this means that once something is committed to that branch, it cannot be "uncommitted" and so you can follow to some extent the student's progress.
  • Due to technical reasons, each repository is started with an initial README.md file. This file is not needed and you can instruct students to delete it (or use it).
  • Each push to the "submit" branch (git submit) is logged, but currently the logs are only available to the system.
  • Using git will automatically use the bodek system, as this is the system that does the checkout. When submitting through git, the submitted tar file (taken out of git) will reside in the ~<course>/course-admin/ directory as usual, and it should be considered as the real submission (not the git's).
  • The repositories are not locked when the deadline has reached. Students can push changes there, but they won't be submitted to moodle (and the students will be notified by mail that their submission have failed).
  • There's one additional repository opened for push for the course's staff and for pull for all students. e.g. intro2cs-2016/ex1. You may use this repository to distribute some material for the students like initial files or some tests. You will have to instruct students how to initially pull the data into their repository and merge if there are changes. If these operation is required and you need help with the merging commands, please contact the system
  • In the future, there might be a status for each submitted commit to indicate if it succeeded or not. This is still under development.