Home
Setup
Committing
Eclipse and Git
FAQ

Configuring Git for Eclipse

Many of the introductory CS courses recommend the use of Eclipse. Luckily, Eclipse can be easily configured to work with your existing Git repository!

To access your Git repository through Eclipse, follow the following steps exactly:

  1. If you are working on a CS system, open up a terminal window.
  2. If you are on your personal machine, choose the appropriate course of action:
    • Linux or Mac machine:
      1. Open the terminal window.
      2. SSH into a CS system with the following command:
        $ ssh {your_username}@glados.cs.rit.edu
      3. Enter your CS password when prompted.
    • Windows machine:
      1. Launch PuTTY.
      2. In the "Host Name" box, put {your_username}@glados.cs.rit.edu
      3. Click "Open".
      4. Enter your CS password when prompted.
  3. Navigate to your home directory:
    $ cd
  4. Create and initialize the Git repository:
    $ git init --bare rit_git
  5. Create a .ssh directory (if one does not already exist):
    $ mkdir -p .ssh
  6. Use the pico text editor to edit the "environment" file in the .ssh directory:
    $ pico .ssh/environment
  7. Add the following line to the file:
    PATH=/opt/csw/bin:/usr/bin
  8. Press Ctrl-X + Y to save.
  9. Get the full path to your current directory:
    $ pwd
  10. Make sure to record the path!! You will need it for the next few steps.
  11. Open Eclipse and connect to your Git repository:
    1. Select Window -> Open Perspective -> Other -> Git .
    2. Click the drop-down arrow in the top-right corner of the Git Repositories pane and select Clone a Repository from the list of options.
    3. Enter the following information and then click Finish:
      Host:               glados.cs.rit.edu
      Repository Path:    {path_from_pwd}/rit_git
      User:               {CS_username}
      Password:           {CS_password}
      Connection Type:    ssh
      (select checkbox for "Store in Secure Store")

      Note: Replace {path_from_pwd} with the string returned by the pwd command, and {CS_username} and {CS_password} with your CS credentials.

      Note: If asked about creating a .ssh/known_hosts file, agree to it.

Committing A Project to a Git Repository

  1. Change back to the Eclipse Java perspective by selecting Window -> Open Perspective -> Java
  2. In the Package Explorer pane, right-click on any project folder and select Team -> Share Project.
  3. Select "Git" and then click Next.
  4. Select the repository you just created and then click Finish.
  5. Right click on the project you just shared and select Team -> Commit.
  6. Enter a meaningful commit message (i.e. "Initial commit"), select the files you wish to include in the commit, and click Commit.
  7. Right click on the project again and select Team -> Push Branch.
  8. Make a small change to the project and make a second commit.
  9. This time, after selecting the files to commit, click Commit and Push. From now on, whenever you want to send your changes to the remote repository, you need to use this button instead of the Commit button.
  10. On your local filesystem, navigate to the rit_git folder where your program files reside and verify that the file you changed is present and correct. This folder is where Eclipse keeps its working copy of the version-controlled content. When you commit through Eclipse, the commit uses this as the source for a new version stored in the project's reposity folder under $HOME/rit_git/.

Note: You should never attempt to add, modify, or delete any files in the $HOME/rit_git/ directory. Doing so would make Git "detect" corruption and refuse to fetch or recover your files!

Checking Out a Project from a Git Repository

The advantage of using a source code repository is that you can work on code on different machines and still keep everything synchronized. Each time you complete a coding session, just commit and push your changes to the remote repository.

Then, next time you work on a different machine, you can either check out the project (for the first time) or pull any changes from the repository.

For example, you can start an assignment on a CS lab machine, commit and push your changes, and then go home and check out the project on your personal machine to continue working right where you left off (even if you use a different operating system)!

To check out a project for the first time in Eclipse:

  1. Select Window -> Open Perspective -> Other -> Git.
  2. In the Git Repositories pane, turn the arrow for the repository icon and the Working Directory down. This will reveal all of your projects in that repository.
  3. Right-click on the project you want and select Import Projects.

Alternatively, to update a project within Eclipse that is already checked out from Git:

  1. In the Package Explorer perspective, right-click on the project folder and select Team -> Pull.