Dmitry Churbanov

Keep it simple, Stupid!
  • Home
  • About Me

Eclipse EGit plugin, part 2

Posted by Dmitry Churbanov on August 11th, 2010 in Development – No comments

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 -> Team -> Add

Add files to Git repository

Commit changes

To commit changes select Team -> Commit. The “Commit Changes” window will pop up and you will need to enter commit message and select what files you want to commit or unselect the files you don’t want to commit. Press “Commit” and all the changes will be committed.

Commit changes

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

Part and Workshop classes

Push changes

To push the changes to the remote repository select Team -> Push. The current version of EGit (0.8.4) has a bug and in most cases push will not work (more is here). There is a small workaround (see Comment #2 in that bug discussion), but it still didn’t work for me on my Ubuntu 10.04. So I did it in command line. (Just after I had published this post I found that EGit doesn’t support pushing via https. More is here.)

Other useful things

The other useful things which you can do with EGit are:

Tags

Select “eclipse_git” project folder -> Team -> Tag. Enter tag name, tag message and press OK button.

Setting Tag in EGit

History of a particular resource

Select any resource (project, package, class, etc) -> Show In -> History. And you can see all the history of the selected resource in the Git repository.

Select EGit history menu item

History in EGit

Branches

If you want to make a branch, select “eclipse_git” project folder -> Team -> Branch.

Making branch in EGit

In the appeared window select “master” in the “Local Branches” category -> press “New branch” button -> enter new branch name -> press OK button. New branch will be created.

Creating new branch in EGit

To switch to the new branch select “eclipse_egit” project folder -> Team -> Branch -> select the branch you want to switch to -> press Checkout button.

Switching to new branch in EGit

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

Tags: eclipse, egit, git

Trackback URI | Subscribe to the comments through RSS Feed

RSS
  • Subscribe: Entries | Comments
  • Archives

    • August 2010 (1)
    • July 2010 (2)
    • December 2009 (1)
  • Tags

    eclipse egit git mercurial

© 2012. Dmitry Churbanov. All rights reserved. Designed by Dmitry Churbanov by reusing SimpleX WordPress theme.