CompSci 308
Fall 2016
Software Design and Implementation

GITing Started

Knowing how to use a source control system will be an invaluable tool for you going forward, perhaps personally, but especially in a team setting. At its heart, version control is just a way to manage the many changes that occur to your files over time, allowing you to revisit previous versions of your code or even work with different versions at the same time. At its best, version control is like a journal that you use to track major, and minor, events in your project. At its most practical, it is like a backup system that prevents you from losing significant work if something happens to your machine. At its worst, it is simply a submit system where you only track your work when told to.

Version control systems have been around for thirty years and GIT is currently the cool tool to use (Linus Torvalds, of Linux fame, created it out of necessity and frustration to help him manage the Linux source code). Using source control well is not difficult, but it does take some practice and a little bit of command-line savvy (we do not suggest using eGit, the Eclipse plug-in, until you are confident in your version control skills).

When running these programs, unless otherwise noted, we suggest following the default options.

Install GIT

Login to Gitlab

  1. Within a Browser, go to the website: https://git.cs.duke.edu/
  2. Press the Shibboleth button to log in using your Duke NetID
  3. After you have successfully been logged in through Duke's standard log in page, there should be a warning at the top of the page saying you need to set up an SSH key
  4. Clicking on that link should take you to a page prompting you to paste the public part of SSH key into the given text area
  5. Next, we will get that key using Eclipse

Generate an SSH Key

  1. Within Eclipse, go to Window -> Preferences -> Network Connections -> SSH2
  2. Choose the tab Key Management and press Generate RSA Key...
  3. Copy the text that appears in the text area using Crtl-C (Windows) or Cmd-C (Mac)
  4. Press Save Private Key... and agree to save it without passphrase protection
  5. Save it using the name id_rsa (no extension) so that it does not conflict with any other SSH keys you may have created in the past and press Okay to close the dialog box
  6. Within a Browser, paste the copied public key into the text area, giving it the same title: id_rsa, and press Add key

Getting Your Own Copy of a Gitlab Project's Starter Code

  1. Within a Browser, click on the Action Menu, (the icon of three bars in the upper left corner) and select Projects -> Explore Projects -> All
  2. Choose the project for this lab, CompSci308_2016Fall/lab_bins
  3. Press Fork and save the project in your own namespace with the same project name (e.g., NetID/lab_bins)
  4. On the new project page that appears, copy the SSH URL (e.g., git@git.cs.duke.edu:NetID/lab_bins.git)

Cloning Your Copy of the Project onto Your Local Machine

  1. Within Terminal, change to your Eclipse workspace folder
        cd WORKSPACE/FOLDER
  2. Download a local version of the project that is linked to your Gitlab repository
        git clone git@git.cs.duke.edu:NetID/lab_bins.git
  3. That command should create a folder named lab_bins within your workspace folder that contains configuration information for both GIT (e.g., .git) and Eclipse (e.g., .project)
        ls -a lab_bins

Importing Your Local Copy into Eclipse

  1. Within Eclipse, select New -> Java Project
  2. Enter the name of the folder you just created: lab_bins, and press Finish
    note, if you type the project name in correctly, all options in the dialog box will grey out (become unedittable)
  3. It should create a project for you within Eclipse that has an annotation next to it referring to your repository name and master

Push Changes to your Project back up to Gitlab

  1. Within Eclipse, open the file README.md by double clicking on it
  2. Add your name and save the file
    when you do this, you should see a greater than sign, >, appear next to the file that indicates GIT knows it has been changed
  3. Within Terminal, add your changed files to those staged for your next commit
        git add README.md
  4. Then note that all the added files should be grouped together into a single commit to the repository, with a message describing the changes contained in this commit
        git commit -m "Included my name in the README"
  5. Push all your commits to the remote repository, e.g., Gitlab, so that others (UTAs, teammates, etc.) can see your changes
        git push -u origin master
  6. Within a browser, refresh the page to see your changed README file

Resources

Submission

Play around with the lab_bins repository, making changes locally through Eclipse, and pushing those changes up to your Gitlab repository. You should commit at least three times and push to Gitlab at least two times.