Basic development collaboration with Git and Eclipse

Last modified by David Nestle on 2019/04/25 14:36

We recommend to use Git as version control system for OGEMA development projects.

Get Access

To checkout Git projects from a Git repository you first have to get access. For public Github projects you can checkout without credentials, but if you plan to commit any changes later on you should checkout with credentials right away. Generation of the keys required is described in the OGEMA Open Source Wiki (Section "Generating a pair of keys"). Send the public key to the owner of the repository. For public open source repositories e.g. on Github no public key is required.

Clone Repositories and Checkout Apps into Eclipse

When you have installed the Demokit you first have to open the Git Perspective. To do this in Eclipse to "Window" -> Perspective -> Open Perspective -> Other, then choose "Git"


Afterwards you can always get back directly to this perspective using the button at the top right. To clone a repository to your local machine, go to "Clone a Git repository" (and enter the access data received) or go to "Add an existing local Git repository" when you have it on your machine already.
To get the access data for public open source repositories e.g. from Github open the repository view in your browser, click on "Clone or Download", then copy the Web-URL and insert it as access data.

Eclipse will show you the repositories it found in your .git folder. You can now import OGEMA Apps as Maven projects: Select the projects to import, right-click and select "Import Maven Projects...", then click Finish. Rundirs cannot be imported as Maven projects - if you want to import a Rundir, select import as existing project. Note that in newer versions of Eclipse there may be just a single option "Import Projects". This should automatically pre-select an import option and show you the import option selected.:


The new project(s) now also appear in the Java Perspective.

Adding new Apps and Projcts

  • If you create a new OGEMA project via File->New->Project->OGEMA (see Hello-OGEMA-App-Tutorial) you can choose "Git" in the Location dropdown and choose a location inside a git repository. This will allow you to directly commit the new app into the respecitve repository. This available in the Eclipse Java Perspective.
  • If you want to copy an exising app, open the location of the source app and the destination Git repository location in your file system explorer (e.g. Windows Explorer). From Eclipse Java Perspective you can open/find such locations in the file system explorer via context menu in the Package Explorer via "Show In"->System Explorer. For OGEMA Apps and other Maven-based projects you just copy the pom.xml and the src folder. You have to open the pom.xml file and change the artifact name, typically also adapt name and description. You can then checkout the project from the Git repository into the Java Perspective as described above. All other adaptations you can make in Eclipse.
    For Rundirs you have to open the .project file and change the project name.

Commiting and Pushing your changes

  • If you are familiar with using Git on the console you can do all Git interaction on the console, of course. Otherwise we recommend the following procedures using Eclipse.
  • Via the Package Explorer context menu you choose Team->Commit, which opens the Git Staging View:
  • In "Unstaged Changes" you see all changes that have been detected by Git/Eclipse that will NOT be committed if you press one of the buttons now. The Staged Changes will be committed. You can move the files between these two fields. If you make your changes in Eclipse the changes will appear in the Git Staging View almost for sure. If you make changes outside Eclipse they may appear when you move any file between the fields or you can choose "Add to index" in the Git View Working Tree on any folder above the changes to make Eclipse/Git search for changes in the directory tree below. Usually you should commit all files except for changes you want to keep local and that do not need backup in the remote Git repository.
  • To make a commit enter a short commit message, the press "Commit and Push...". Only choose "Commit" if you need an intermediate commit that shall not be transferred to the remote Git used for collaborative development. Note that without Pushing the commit remains on your local machine only and thus has no backup on another machine (but you still can get back all local commits via Git).
  • If the commit could be pushed successfully you should get a message like this:
  • If somebody else pushed something since your last Pull from the Repository you will get a message that the Push was not possible because the content from the Commit of your OGEMA colleague that was pushed in the meantime and your new conent have to be merged first:

    In this case you have to perform a Pull from the Remote Repository (either via Team -> Pull or directly in the context menu in the Git Perspective). If you colleague did not make changes to any file you changed in the meantime or if such files can be merged automatically you will get a success message:
  • If the Result is "Merged" as shown above finally perfom a "Push to Upstream", then you are done. In the Package Explorer you will see small arrows when the project has commits that are not in sync with the remote repository, so finally there should be no arrows anymore.
  • If no automated merge is possible the Result will be "Conflicting". the conflicting files will be marked red in Eclipse. You have to edit them manually. They will contain both you changes and the changes of your colleague with a notice which content is from which source. When you finished editing you have to perform an "Add to Index" on the Conflicting file. When you have resolved all conflicts you have to perform another commit on the merge (not necessary if the automated merge was successful).

Tips for using Git

git remote -v
to display the current settings, e.g. output:
    origin   (fetch)
    origin   (push)

To set new URL:
git remote set-url origin <neue URL>

E..g. for new OGEMA server:
git remote set-url origin 
Created by David Nestle on 2018/02/01 09:57