Eclipse EGit plugin, part 2
In the previous post we discussed how to import remote Git repository. Now let’s look which Git commands are available in EGit plugin. EGit plugin is still not completely ready and does not support all Git commands. You can watch “Understanding and Using Git at Eclipse” webinar to learn what is ready and what the plans are.
In this post I will continue to use the same remote repository which was used in the previous post.
Basic operations
In the first post about Git we discussed the basic Git operations. Now let’s see how you can do the same using EGit plugin.
Add files
Create com.churbanov.tutorial.egit package and the following two classes.
package com.churbanov.tutorial.egit;
/**
* Represents workshop where different works with cars, boats
* and other vehicles can be done.
*
* @author Dmitry Churbanov
*/
public class Workshop {
public static void main(String[] args) {
System.out.println("Welcome to our Workshop!");
}
}
package com.churbanov.tutorial.egit;
public class Part {
private Long id;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Now we need to tell Git to start tracking just added classes. To do so, we select Part.java and Workshop.java classes in eclipse package explorer

Commit changes
To commit changes select Team

After commit you can see that Workshop.java and Part.java files icons are changed in package explorer.

Push changes
To push the changes to the remote repository select Team
Other useful things
The other useful things which you can do with EGit are:
Tags
Select “eclipse_git” project folder

History of a particular resource
Select any resource (project, package, class, etc)


Branches
If you want to make a branch, select “eclipse_git” project folder

In the appeared window select “master” in the “Local Branches” category -> press “New branch” button

To switch to the new branch select “eclipse_egit” project folder

Useful links
Using Git: http://www.churbanov.com/blog/2010/07/08/using-git-part-1/
Eclipse EGit plugin: http://www.churbanov.com/blog/2010/07/12/eclipse-egit-plugin/
EGit user guide: http://wiki.eclipse.org/EGit/User_Guide
Git community book: http://book.git-scm.com/
Git reference site: http://gitref.org/index.html