This article discusses how to set up and use eGit (the Eclipse version of Git) with Eclipse version 3.7.2 (available as of March 2012). It is important to have the latest version of Eclipse in order to use the latest (and most stable) version of eGit.

This article discusses how to set up and use eGit (the Eclipse version of Git) with Eclipse version 3.7.2 (available as of March 2012). It is important to have the latest version of Eclipse in order to use the latest (and most stable) version of eGit.

If you have an older version of Eclipse, it is quite easy to try the latest version without removing your old version. Simply install the new version in a different directory than the existing Eclipse version and use the same Eclipse workspace. All of your projects and preferences are saved in the workpace and will be available to the new Eclipse version. If for some reason you need to go back to your old Eclipse version, just close the new version and start the old one.

If you have an older version of Eclipse, it is quite easy to try the latest version without removing your old version. Simply install the new version in a different directory than the existing Eclipse version and use the same Eclipse workspace. All of your projects and preferences are saved in the workpace and will be available to the new Eclipse version. If for some reason you need to go back to your old Eclipse version, just close the new version and start the old one.

+

+

There is an excellent tutorial on getting started with Eclipse and EGit at [http://www.vogella.com/articles/EGit/article.html vogella.com/articles/EGit/article.html].

=Installing Eclipse with PHP and Git=

=Installing Eclipse with PHP and Git=

−

To Install Eclipse with PHP and Git, follow these steps:

+

To Install Eclipse with PHP and Git, follow these steps (as of April 2014 Eclipse "Kepler" comes with Git already included):

# Install Eclipse for Javascript Web Developers from [http://eclipse.org/downloads/ Eclipse Downloads]. This will give you a version of Eclipse with XML and HTML file editing (but without eGit or PHP).

# Install Eclipse for Javascript Web Developers from [http://eclipse.org/downloads/ Eclipse Downloads]. This will give you a version of Eclipse with XML and HTML file editing (but without eGit or PHP).

# To add eGit and PHP, navigate to Eclipse&rarr;Help&rarr;Install New Software, as shown below. [[File:eclipse-install-372-screenshot-01.png|frame|none]]

# To add eGit and PHP, navigate to Eclipse&rarr;Help&rarr;Install New Software, as shown below. [[File:eclipse-install-372-screenshot-01.png|frame|none]]

Line 17:

Line 18:

=Creating a Project from a Remote Repository=

=Creating a Project from a Remote Repository=

−

[[File:git-eclipse-screenshot-01.png|frame|none]]

+

−

[[File:git-eclipse-screenshot-02.png|frame|none]]

+

Normally the first task we need to do is to create an Eclipse project from a remote Git repository (usually on Github). The repository might be a fork we have created for our own use or it might be a Joomla project (CMS or Platform) or someone else's project. In any case, we follow the same three steps:

−

[[File:git-eclipse-screenshot-03.png|frame|none]]

+

# Clone the remote repository into a local Git repository.

−

[[File:git-eclipse-screenshot-04.png|frame|none]]

+

# Create a new PHP project in our Eclipse workspace.

−

[[File:git-eclipse-screenshot-03a.png|frame|none]]

+

# Share the project. This associates the Eclipse project with the local Git repository.

−

[[File:git-eclipse-screenshot-04a.png|frame|none]]

+

−

[[File:git-eclipse-screenshot-05.png|frame|none]]

+

Note that there are different ways to accomplish this. Here are detailed instructions for one way to do this.

−

[[File:git-eclipse-screenshot-06.png|frame|none]]

+

==Clone the Remote Repository==

−

[[File:git-eclipse-screenshot-07.png|frame|none]]

+

One easy to way to clone a remote repository is using the Git Repositories view in Eclipse. Here are the steps:

−

[[File:git-eclipse-screenshot-07a.png|frame|none]]

+

# Open the Git Repositories view (Windows&rarr;Show View&rarr;Git Repositories) and click on the Clone button as shown below.[[File:git-eclipse-screenshot-01.png|frame|none]]

# At this point, we need the URL from Github. We can use either SSH or HTTPS. SSH requires that you have created SSH keys in Github and stored them in Eclipse. Find the desired repository in Github. To use SSH, select the SSH tab and Copy to Clipboard button.[[File:git-eclipse-screenshot-03.png|frame|none]]

−

[[File:git-eclipse-screenshot-10.png|frame|none]]

+

# Paste this value into the URI value in the Eclipse form and select SSH as the protocol and check the box "Store in Secure Store", as shown here.[[File:git-eclipse-screenshot-04.png|frame|none]] Then click Next.

−

[[File:git-eclipse-screenshot-11.png|frame|none]]

+

# If you want to use HTTPS instead of SSH, in Github select the HTTP tab as shown here.[[File:git-eclipse-screenshot-03a.png|frame|none]]

−

[[File:git-eclipse-screenshot-12.png|frame|none]]

+

# For HTTPS, select HTTPS as the protocol and fill in your Github user name and password, again checking the box "Store in Secure Store". This is shown below.[[File:git-eclipse-screenshot-04a.png|frame|none]] Then click Next.

−

[[File:git-eclipse-screenshot-13.png|frame|none]]

+

# Here we select the branch to track. Normally this is the master branch, as shown here.[[File:git-eclipse-screenshot-05.png|frame|none]]Select the desired branch and click Next.

−

[[File:git-eclipse-screenshot-14.png|frame|none]]

+

# Next we select the local destination for the repository. This will normally be the same as the project location for the PHP project. The remote repository name defaults to "origin", as shown in the example below.[[File:git-eclipse-screenshot-06.png|frame|none]] Then click finish to create the repository.

−

[[File:git-eclipse-screenshot-15.png|frame|none]]

+

#:''Note that the eGit Help documentation advises against storing the local Git repository in the project folder. However, in practice this appears to the best way to do it.''

+

# At this point, the repository should show in the Git Repositories view as shown here (for SSH).[[File:git-eclipse-screenshot-07.png|frame|none]]Note that the remote repository shows under the name "origin". If you used HTTP instead of SSH, the origin repository will show as follows.[[File:git-eclipse-screenshot-07a.png|frame|none]]

+

+

==Create the PHP Project==

+

+

At this point, we have the local repository created. Now we want to create a PHP project in the same directory that we used for the repository. Here are the steps.

# Enter the directory for the new project. This will normally be the same as we used for the local repository, as shown here.[[File:git-eclipse-screenshot-09.png|frame|none]]Note that we get the warning message indicating that the location already exists. That is expected.

+

# Click Finish to create the project. At this point, we should have the PHP project with all of the files from the remote repository, as shown here.[[File:git-eclipse-screenshot-10.png|frame|none]]

+

+

==Share the PHP Project==

+

+

At this stage, we have our local project in Eclipse. However, it is not associated with the Git repository. To do that, we have to "share" the project. Here are the steps.

+

# Right click on the project to show the context menu. Select Team&rarr;Share Project as shown below.[[File:git-eclipse-screenshot-11.png|frame|none]]

+

# The Share Project form will show. Select Git and click Next.[[File:git-eclipse-screenshot-12.png|frame|none]]

+

# The Configure Git Repository form will show. Click on the check box "Use or create repository in parent folder of project", as shown below.[[File:git-eclipse-screenshot-13.png|frame|none]]

+

# Now the form should show as shown below.[[File:git-eclipse-screenshot-14.png|frame|none]]Click Finish.

+

+

At this point, our PHP project is now under version control using the local clone of the remote repository. If we close the project and re-open it, we should see the small orange "decorators" next to each file and folder under version control, as shown below.[[File:git-eclipse-screenshot-15.png|frame|none]]

[[Category: Bug Squad]] [[Category: Development]]

[[Category: Bug Squad]] [[Category: Development]]

+

[[Category:GitHub]]

+

[[Category:IDE (Integrated development environment)]]

Latest revision as of 04:10, 6 April 2014

Contents

Introduction

This article discusses how to set up and use eGit (the Eclipse version of Git) with Eclipse version 3.7.2 (available as of March 2012). It is important to have the latest version of Eclipse in order to use the latest (and most stable) version of eGit.

If you have an older version of Eclipse, it is quite easy to try the latest version without removing your old version. Simply install the new version in a different directory than the existing Eclipse version and use the same Eclipse workspace. All of your projects and preferences are saved in the workpace and will be available to the new Eclipse version. If for some reason you need to go back to your old Eclipse version, just close the new version and start the old one.

Installing Eclipse with PHP and Git

To Install Eclipse with PHP and Git, follow these steps (as of April 2014 Eclipse "Kepler" comes with Git already included):

Install Eclipse for Javascript Web Developers from Eclipse Downloads. This will give you a version of Eclipse with XML and HTML file editing (but without eGit or PHP).

To add eGit and PHP, navigate to Eclipse→Help→Install New Software, as shown below.

Select Indigo update site as shown below.

This will present a list of all of the available Eclipse plugins. Select the three git options under Collaboration, as shown below.

Then select the PHP Development Tools (PDT) option under Programming Languages as shown below:

Then click through the rest of the wizard and accept the terms of the license agreement. At this point, the requested plugins will be downloaded. After this, you will be prompted to restart Eclipse (which you should do).

At this point, you should have PHP and eGit installed with Eclipse. Confirm this by selecting Window→Open Perspective→Other and make sure that the PHP and Git Repositories perspectives show on the list.

Creating a Project from a Remote Repository

Normally the first task we need to do is to create an Eclipse project from a remote Git repository (usually on Github). The repository might be a fork we have created for our own use or it might be a Joomla project (CMS or Platform) or someone else's project. In any case, we follow the same three steps:

Clone the remote repository into a local Git repository.

Create a new PHP project in our Eclipse workspace.

Share the project. This associates the Eclipse project with the local Git repository.

Note that there are different ways to accomplish this. Here are detailed instructions for one way to do this.

Clone the Remote Repository

One easy to way to clone a remote repository is using the Git Repositories view in Eclipse. Here are the steps:

Open the Git Repositories view (Windows→Show View→Git Repositories) and click on the Clone button as shown below.

Select URI and click Next.

At this point, we need the URL from Github. We can use either SSH or HTTPS. SSH requires that you have created SSH keys in Github and stored them in Eclipse. Find the desired repository in Github. To use SSH, select the SSH tab and Copy to Clipboard button.

Paste this value into the URI value in the Eclipse form and select SSH as the protocol and check the box "Store in Secure Store", as shown here.

Then click Next.

If you want to use HTTPS instead of SSH, in Github select the HTTP tab as shown here.

For HTTPS, select HTTPS as the protocol and fill in your Github user name and password, again checking the box "Store in Secure Store". This is shown below.

Then click Next.

Here we select the branch to track. Normally this is the master branch, as shown here.

Select the desired branch and click Next.

Next we select the local destination for the repository. This will normally be the same as the project location for the PHP project. The remote repository name defaults to "origin", as shown in the example below.

Then click finish to create the repository.

Note that the eGit Help documentation advises against storing the local Git repository in the project folder. However, in practice this appears to the best way to do it.

At this point, the repository should show in the Git Repositories view as shown here (for SSH).

Note that the remote repository shows under the name "origin". If you used HTTP instead of SSH, the origin repository will show as follows.

Create the PHP Project

At this point, we have the local repository created. Now we want to create a PHP project in the same directory that we used for the repository. Here are the steps.

Select File→New→PHP project as shown here.

Enter the directory for the new project. This will normally be the same as we used for the local repository, as shown here.

Note that we get the warning message indicating that the location already exists. That is expected.

Click Finish to create the project. At this point, we should have the PHP project with all of the files from the remote repository, as shown here.

Share the PHP Project

At this stage, we have our local project in Eclipse. However, it is not associated with the Git repository. To do that, we have to "share" the project. Here are the steps.

Right click on the project to show the context menu. Select Team→Share Project as shown below.

The Share Project form will show. Select Git and click Next.

The Configure Git Repository form will show. Click on the check box "Use or create repository in parent folder of project", as shown below.

Now the form should show as shown below.

Click Finish.

At this point, our PHP project is now under version control using the local clone of the remote repository. If we close the project and re-open it, we should see the small orange "decorators" next to each file and folder under version control, as shown below.