Search Engine

Thursday, November 11, 2010

Putting projects under version control

The following section explains how to create a repository for one project and shows how to checkout an exiting projects from a remote repository.

4.1. Put a new project under version control

Create a project "de.vogella.git.first". Create the following class.

package de.vogella.git.first;

public class GitTest {

* @param args
public static void main(String[] args) {
System.out.println("Git is fun");

Right click your project, select Team -> Share -> Git. Select the proposed line and press "Create repository". Press finish.

You have created a local Git repository. The git repository is in this case directly stored in the project in a ".git" folder.

Create the file ".gitignore" in your project with the following content. All files / directories which apply to the pattern described in this file will be ignored by git. In this example all files in the "bin" directory will be ignored.


4.2. Clone existing project

EGit allows to clone an existing project. We will use an Eclipse plugin as example. To learn more about accessing standard Eclipse coding please see Eclipse Source Code Guide .

Select File -> Import -> Git -> Git Repository. Press clone and maintain the git repository "git://". You only have to paste the URL to the first line of the dialog, the rest will be filled out automatically.

After pressing next the system will allow you to import the existing branches. You should select at least "master".

The next dialog allow you to specify where the project should be copied to and which branch should be initially selected.

You get an additional import dialog.

You have checked to the project and can use the team Git operation on your project.

4.3. Repository view

EGit has a "Git repository"" view which allow you to browse your repositories, checkout projects and manage your branches.


Post a Comment