This how-to is served as my memo to import a Bitbucket project into Eclipse. First things first, make sure you have an up-and-running Eclipse with EGit (in this how-to I am using Eclipse Indigo 3.7.2 with EGit 1.3.0)

  • Create a folder to hold the workspace for your new project (You can skip this step if you want to use an existing workspace), I will use one of my project on Bitbucket in this how-to. It's GreenMail web application. So I create a folder name greenmail-webapp
  • Open the Git Repositories view (it's under Windows -> Show View -> Other..., then under the Git category).
  • Click 'Clone a Git repository' and paste in the whole Git repo URL to the URI textbox, EGit will automatically fill in other textbox with the right value (so cool!), all you need is to enter the correct password. Then click 'Next'.
  • At the Branch Selection screen you are able to choose a branch to clone, my project has only one branch (master). If you clone an empty project from Bitbucket, just click next.
  • At the Local Destination, browse to your workspace directory for this project. I usually don't check-in the .project and .classpath files into the VCS, I just generate them locally right after I checkout/clone instead. If your build tool does not generate those files for you or you are the only one in this project, it'd better to check-in those files.
  • Now, let's generate the Eclipse project files. I use Gradle as my build system, so it's just a command away.
    gradle eclipse
    
    Before running this, make sure you've already applied the 'eclipse' plugin in your build.gradle. If you use Maven, please include the maven-eclipse-plugin into your pom.xml and run the command
    mvn eclipse:eclipse
    
    The above commands will generate/overwrite the .project and .classpath for you.
  • Returning to your Eclipse, you can now Import your new cloned project into your workspace by right clicking on your in the Git Repository view, select Import Projects...

  • Select Import existing projects
  • Select the project you want to import.

Happy coding!

9 comments:

erre on July 20, 2012 at 1:00 AM

Thanks a lot!!!!

Anonymous on August 24, 2012 at 12:41 PM

Thanks! :-) Was very helpful

Anonymous on October 29, 2012 at 12:12 PM

Very helpful. Thanks!

Unknown on December 24, 2012 at 4:01 AM

Hi I try to clone the toxiclibs but all I get, when getting to the branch selection is:

Exception caught during execution of ls-remote command:
https://bitbucket.org/postspectacular/toxiclibs:

Whats wring with that?

Unknown on February 19, 2013 at 6:08 PM

I am getting the same error. Should be my eclipse setting

Unknown on May 9, 2013 at 12:45 AM

Hi there, I've some troubles during the import step.
That's true, when you click on "Clone a Git Repository" EGit fills all the text fields but I think in an incorrect way.
First of all my url is something like git@bitbucket.org[...]
and it fills the user field with "git" but I'm not "git" :(
And then it tries to log me with that user name...
If I try to change it in my actual user name it modifies the url to myuser@bitbucket.org[...] and this is again not correct!
Any suggestion?
Thanks!

Unknown on June 24, 2013 at 1:53 PM

Nice!

Anonymous on October 24, 2013 at 5:42 AM

Thanks It worked as a charm !!

Anonymous on February 27, 2014 at 10:26 PM

Thank you. This helped a lot for the android project I need to work on.
But after I connected to bitbucket repo and downloaded the code to my local drive, I had to import the project via File-->Import --> Existing Android Into Workspace.

Post a Comment