Setup a Git-hosted Project in Eclipse

If you’re used to using Visual Studio and Source Depot, then you’re in for a bit of a paradigm shift when you use Eclipse and git.

Note: The location of your Eclipse Workspace, and the location of your source code are mutually exclusive. I.e., you might think that the workspace should encompass your local git repo – but it doesn’t, and actually can’t. For example, I have all of my local repos on the C: drive (in C:\Users\Chris\src\), yet I have my default Workspace on my A: drive (in A:\Documents\Eclipse\Projects\).

Think of it like this: when a multi-media app manages your music collection, it doesn’t move all of your media files into it’s program directory. Instead, it builds a database the contains records for corresponding media files. Each record contains a pointer to the media file, along with all of the details contained in its ID3 tag.

You’re doing something similar when you build an Eclipse Workspace. In the case of Eclipse though, the database is stored in a “Workspace;” a folder on your file system that contains a folder called “.metadata”.

Window > Preferences > Teams > Git

Default Repository Folder (Git_HOME):


Eclipse reads these details straight from your user configuration file (%USERPROFILE%.gitconfig).

The only thing I had customized in this file was my merge tool: “C:\Program Files (x86)\Beyond Compare 4\BCompare.exe”

name = Chris Boorman email =
tool = bc
[difftool “bc”]
path = C:\Program Files (x86)\Beyond Compare 4\BComp.exe
tool = bc
[mergetool “bc”]
cmd = “C:\Program Files (x86)\Beyond Compare 4\BComp.exe” “$LOCAL” “$REMOTE” “$BASE” “$MERGED”
default = simple

To work on Git-hosted projects in Eclipse, you must import them into Eclipse using the Git Project Import Wizard. You can use Import Existing Project.

The procedure differs between projects hosted publicly on GitHub, and projects hosted on 3rdParty’s private repo server.

3rdParty private server

Here’s how to get a local enlistment to the privately hosted 3rdParty REST API Git repository. Before you begin, establish a VPN connection to 3rdParty.

  1. In Eclipse, open the Git perspective.
  2. In the Git Repositories pane, click Clone a Git repository
    The Clone Git Repository dialog appears.
  3. In the Connection Protocol drop-down list, select git.
  4. In the URI field, type the URI of the Git repository, and then click Next.

    You’re prompted to input your password.

  5. In the Information dialog, type your SSH Passphrase, and then click OK.
    The Branch Selection dialog appears.
  6. Select branches to clone from the remote repository. Remote tracking branches are created to track updates for these branches in the remote repository.
    Click Deselect All, and then check the following branches: develop, feature/api_doc, master, release/current; and then click Next.
    The Local Destination dialog appears.
  7. Set the Initial branch to feature/api_doc, and then click Finish.
  8. In Eclipse, in the Project Explorer, right-click the background, and select Import > Import > Git > Projects from Git > Existing Local Repository.
    The Select a Git Repository dialog appears. Note that the repository you want isn’t in the list! Don’t worry though…
  9. Click Add.
    The Add Git Repositories dialog appears. The new repository is already checked (and in my case – along with the Java repo).
  10. Click FinishNext.
  11. Select Import as a General Project, and click Next.
    The new project folder appears selected: Working Directory – C:\Users|Chris\src\mobile_assets
  12. Accept the suggested project name (mobile_assets), and click Finish.

3rdParty on GitHub

To work on a project hosted on GitHub:

  1. Navigate to that project repo on GitHub.
  2. Click Fork. This creates a copy of the project repository under your account.
  3. Navigate to your new forked project on GitHub, and click Clone. This creates a local copy of the project repository on your hard drive.

Leave a Reply