Home > Eclipse, P2 > How to use git to solve and submit your exercises

How to use git to solve and submit your exercises

February 25th, 2010

You need git to send in assignments. You will receive the skeletons for your solution through git, presumably use git to version your intermediate steps, and when you’re all done, you’ll push your changes to the server, where we’ll grade them. This file tells you the few basic commands that you’ll need to solve the exercises.

This article is also available as a presentation: Git tutorial.

Where to get git

Download:

  • Cygwin for Windows (don’t forget to include the git package)
  • Git everyone else

Generate your ssh key

Here, and in the rest of this text, lines that start with a dollar sign ($) are to be issued on the command line (without the dollar sign itself, of course).

If you know what you’re doing, you can skip this. This creates your ssh key:

$ ssh-keygen -t rsa

Send us your ssh key

Mail the ~/.ssh/id_rsa.pub (note: only .pub file!) to: patrik.rauber@students.unibe.ch. Then, receive your confirmation.

Clone your group’s repository

$ git clone git@pinocchio.unibe.ch:groupXY

(where XY is your group number)

$ cd groupXY

Configure git

Issue the following commands:

$ git config --global user.name "YOUR NAME"
$ git config --global user.email "your@email.com"

$ git remote add p2ubungen git@pinocchio.unibe.ch:p2ubungen


Get exercise skeletons

These are the code skeletons that you will have to adapt or look at for completing your tasks. The following command copies the skeleton into your repository.

$ git pull p2ubungen master

Set up Eclipse

Eclipse is the program where you’ll write your code. Get it from eclipse.org/galileo.

Now, open Eclipse. Set your workspace to the folder: “groupXY”, i.e. the repository root.

Import p2regex project with by choosing from the menu:
File > Import … > General > Existing Projects into Workspace.

Workflow

Here are the commands that will get the code into your local repository, and into the public server, that your group and the TAs can see.

Retrieve latest exercise skeletons from server

$ git pull p2ubungen master

Retrieve your group’s changes from server

$ git pull

Commit to your local repository ###

$ git add *
$ git commit -m “I changed something!”

Retrieve your group’s changes from server

$ git pull

Upload to server

$ git push

Verify that everything went good with git

As you work, to see the status of git (what it’s about to commit, what’s in the repository and what isn’t, etc.) you can issue:

$ git status

Verify thoroughly that everything went good with git

After finishing your work, check that everything was pushed:
$ cd /tmp
$ git clone git@pinocchio.unibe.ch:groupXY
$ cd groupXY
$ ls -lh

More info on git

http://sunoano.name/ws/public_xhtml/scm.html.

Here, replace “I changed something” with a good and long description of what you changed.

nes1983 Eclipse, P2

Comments are closed.