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):
${env_var:GITSOURCE}/
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”
- [user]
- name = Chris Boorman email = cboorman@3rdParty.com
- [diff]
- tool = bc
- [difftool “bc”]
- path = C:\Program Files (x86)\Beyond Compare 4\BComp.exe
- [merge]
- tool = bc
- [mergetool “bc”]
- cmd = “C:\Program Files (x86)\Beyond Compare 4\BComp.exe” “$LOCAL” “$REMOTE” “$BASE” “$MERGED”
- [push]
- 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.
- In Eclipse, open the Git perspective.
- In the Git Repositories pane, click Clone a Git repository
The Clone Git Repository dialog appears.
- In the Connection Protocol drop-down list, select git.
- In the URI field, type the URI of the Git repository, and then click Next.
git@git.c11.3rdParty.com:python_rest_api.git
You’re prompted to input your password.
- In the Information dialog, type your SSH Passphrase, and then click OK.
The Branch Selection dialog appears.
- 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. - Set the Initial branch to feature/api_doc, and then click Finish.
- 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…
- Click Add.
The Add Git Repositories dialog appears. The new repository is already checked (and in my case – along with the Java repo).
- Click Finish, Next.
- Select Import as a General Project, and click Next.
The new project folder appears selected: Working Directory – C:\Users|Chris\src\mobile_assets
- Accept the suggested project name (mobile_assets), and click Finish.
3rdParty on GitHub
To work on a project hosted on GitHub:
- Navigate to that project repo on GitHub.
- Click Fork. This creates a copy of the project repository under your account.
- Navigate to your new forked project on GitHub, and click Clone. This creates a local copy of the project repository on your hard drive.