Bruno Raljić

A Java Developer's Blog

Setting up git with eclipse step by step

This is the step-by-step article for setting up your eclipse to work with git repositories. I’m writing this for myself to use as a reminder later, because it’s the first time I set up git with eclipse. If you see I’m doing something wrong, please let me know.

Set up eclipse and plugins

I chose eclipse indigo because eclipse juno seemed really slow for me (when switching between xml and java files). After you get your eclipse, go to the eclipse marketplace and download a plugin for git.

egit eclipse marketplace

Because this is the maven project, I’ll download a plugin for maven.

Now, use the eclipse shortcut CTRL + 3 for quick navigation and type in git to select Git Repositories view.

Now select the Clone a Git repository. I created new git repository via browser so I’ll just clone it.

As location URI provide a link you can find when you open your project in the browser.

Provide your credentials and hit next. As a local destination direcory provide a directory in your eclipse workspace. Replace the project with your project name if you want.

Now you’ll have your git repository.

Right click on your project name (in my case beunique folder) and select Import project. I chose to import as general project.

Now you have your project in the workspace. Because it’s the maven project and you’ve imported it as a general project, you need to convert it to maven project. Right click on your project nad select Configure > Convert to Maven project (this option is provided with maven plugin we installed).

Now you have your project ready for developement.

First commit/push

Git repositories are organized more like mercurial repositories. If you coming from SVN, you’ll know only about commit operations. Here you have your local repository and your remote repository. So, first you need to commit to your local repository and then push your changes to the remote repository.

After your changes, right click on your project and synchronize. You’ll see the files you worked on as usual. If you agree with all this changes, right click and select Commit. Provide a comment for your commit and click Commit and Push button. This is the difference, if you click only Commit button, you’ll commit your changes only to your local repository. But with this, you did both commiting and pushing it to the remote repository.

To assure you push it correctly, you can see the changes in your github project via the browser.

Conclusion

OK, those were the steps for getting your project from github repository. Maybe you’ll find out few steps more during your setting (related to the user credentials perhaps). I wrote this blog while doing actual step by step configuration, but because I already set up the repository once before on my computer, it may have some values stored already.

Once again, this is the step-by-step configuration for the begginers. I didn’t use github before and when I try to set it up for the first time I got some “unexpected behaviour”. So, I can use this article also as a reminder.

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Show my latest blog post with this comment!