In the previous post we discussed how to import remote Git repository. Now let’s look what 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.
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.
com.churbanov.tutorial.egit package and the following two classes:
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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
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.
After commit you can see that Workshop.java and Part.java files icons are changed in package explorer.
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:
Select “eclipse_git” project folder -> Team -> Tag. Enter tag name, tag message and press OK button.
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.
If you want to make a branch, select “eclipse_git” project folder -> Team -> Branch.
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.
To switch to the new branch select “eclipse_egit” project folder -> Team -> Branch -> select the branch you want to switch to -> press Checkout button.
- 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