a single project with EGit (Git) repository

This workflow is part of my DVCS blog series. If you don’t understand some steps, please read the first parts of the series.

The goal: a single project from Workspace with Git Repository using EGit

Most times your repositories will contain more then one project. How to do this is explained here for EGit and here for HgEclipse. But sometimes you only want to put a single project under control of a DVCS to use branching etc. This workflow will demonstrate how easy you can share a single project.

The short story:

  1. Share one project
    1. Share the project (create Repository)
    2. Add ressources to Repository
    3. Commit to Repository
  2. You’re done: a project in your workspace shares a Repository

the long story:

1. Share one project

1.1 Share the project (create repository)

Go to your Project from Package Explorer and right-click “Team -> Share project…“:

select “Git” as Provider, as next select the line and click “Create Repository“:

and hit “Finish“.

Now the Repository is created and the project decorated as “under version control”:

Ressources not yet in your repository are marked with a question mark, the project itself is marked as “master”.

1.3 Add ressources to Repository

As next we have to add the missing ressources to the repository: “Team -> Add to Version Control…

then the Ressources are decorated as “Added, but not committed”:

Unfortunately at the moment there are two steps neccesary: add and then commit, but there’s discussion to combine this: Bugzilla 303373.

1.4 Commit to Repository

Team -> Commit…” shows this dialog, please enter a message:

Hit “Commit” and your project is under Version Control.

2. You’re done: a project in your workspace shares a Repository

We can’t control the repository from a Git View, but if we take a look at the file system, we can see that the repository is created successfully into your Project – directory:

To solve the same task using Mercurial /HgEclipse: here’s the workflow.

This workflow is part of my DVCS blog series – an overview of all workflows can be found here.


2 responses

  1. I just tried this with EGit in Eclipse 3.7 Indigo. Sharing a project will not allow the repository to reside within the project folder. There is an option to use the parent folder of the project, but this will balk if the parent folder is the current Eclipse workspace. Perhaps, the recommendations presented here, http://wiki.eclipse.org/EGit/User_Guide#Creating_Repositories are being enforced in the tool? The final result is that the existing project in the intended Eclipse workspace, is instead, “moved” to a new or existing egit repository in HOME.

    The Mercurial plugin, does allow this.

    Just a quick test, so very possible I’m missing some subtlety.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s