Using, Part II

In this followup post to the original posting on this subject, we  deal with how to work with changes in the source code.  There are various sorts of situations we need to handle:

  1. You want to push your work from your local repository to your gitorious repository, either to make it available to your team members, or to turn it in to me.
  2. You need to update your version of my repositories.  This can happen in two ways:
    1. the jReality clone which you used to set up your workspace has  been changed — typically to add a feature or fix a bug which is relevant to our class work.
    2. the course repository has been updated with a new assignment which you need to integrate into your workflow.

The solutions presented below — in contrast to the original post for gitorious — are based on the git command-line interface.  So to use them, you need to have a shell open.  Commands in this shell will be indicated by a leading ‘%’ to indicate a shell prompt.

Preliminary repair work. Before beginning we need to do a little repair work.  Change directory to where your local git repository for the course is, and then change directory into the .git subdirectory.  Use a text editor to edit the file config, to replace any occurrences of the string “assg1” with “master” (this reflects the fact that I have changed the course repository on gitorious to have only a single branch named “master”; having more was just going to be too complicated for everyone).  If you have any questions, wait until the next tutorial meeting to carry this out.

Push your work up to your gitorious repository. The solution to 1. above is simple.

  1. First we give the commands, then we explain them:
    • % cd my_local_git_repository
    • % git add .
    • % git commit -m “My version of Assignment1”
    • % git push
  2. The ‘add’ command adds any files you’ve created to the list of changes to be committed to your local repository.  The ‘commit’ command commits these changes to your local repository.  The ‘push’ command propagates them to your gitorious repository.
  3. If you have your ssh keys properly installed, this should propagate your changes to your gitorious repository.
  4. Now you can notify your team member of the changes, or if the changes represent something that I should see, send me an e-mail notifying me.  Be sure to paste the string for your gitorious repository into the e-mail, so I can install it into my eclipse workspace in case I don’t already have it or identify it (if I have installed it).
  5. If you want to update from your repository (either because you’ve updated it from another computer or a collaborator has done so), use the command
    • % git pull
    • or, in eclipse, “Team->pull”

Update your jreality to the latest version.

  1. Issue the following commands in a shell:
    • % cd my_local_jreality_repository
    • % git status
    • % git checkout origin/develop -b develop
  2. If the last command complains that the branch “develop” already exists, then just omit the “-b develop”.
  3. From now on, to update jReality you can issue the command
    • % git pull
    • or, inside of eclipse, “Team->pull”

Update to the latest version of the course repository tu-mathvis-ws13.

In the course of the semester there will be new assignments that you need to “download” from the course repository.  They do not immediately show up on your cloned gitorious repository.  This is the most complicated procedure since it represents an independent branch of the repository which has to be merged into your working version. Here is how you can update using the git command line.

  1.  Then issue the following commands in a shell:
    • % cd my_local_tu-mathvis-ws13_repository
    • % git status
    • % git remote add teacher git://
    • % git fetch teacher
    • % git checkout teacher/master -b teacher
    • % git checkout master
    • % git merge teacher
  2. Explanation: The “status” command should show a “clean” branch — one with no changes that need to be committed.  If there are un-committed changes, commit them first.  The “remote” command adds a new remote reference to your git repository with the name “teacher”.  This is my original repository that you cloned on gitorious. The “fetch” command brings over the current version of this “teacher” repository into your local repository. The first “checkout” command checks out the “master” branch of this “teacher” repository, and creates a new local branch named “teacher” for it.  The second “checkout” command reverts the current working directory to the “master” branch of your local repository.  The “merge” command merges the “teacher” branch into this local “master” branch.  If you have been following the rules for development, then the changes from teacher and the changes you makes should be mutually exclusive and the merge should be trivial.
  3.  You can then commit the changes and push the result onto your gitorious repository following the instructions at the beginning of this document.

5 thoughts on “Using, Part II

  1. Pingback: Using, Part I | Mathematical Visualization

  2. Pingback: Course Log | Mathematical Visualization

  3. Pingback: Next Lecture Todo List | Mathematical Visualization

  4. Pingback: 04.11 Next Lecture TODO List | Mathematical Visualization

Leave a Reply