How to share eclipse project to github and viceversa

In this tutorial, let us  see how to share any eclipse project to Git repository (github.com) and also we will see how to  to check out  the github repository  project in Eclipse.

In this example, let us share the project named JavaRestService to git and vice versa.

PART I) Steps to share eclipse project to Github repository.

1. Create a new local git repository or use an  existing one and share the project.  For creating local git repository, right click on the project and select Team->Share Project->Git

step2

step3

2. Select any local folder (in this example, C:\GitRepos\JavaRestService) as Repository to store the project and click on Finish

step7

Please ensure that the folder C:\GitRepos\JavaRestService is created

3. Click on Next and Finish.

step8

4. Commit the project.  For committing the project, right click on the project and select Team->Commit

step9

step10

Select all the files to be committed and Click on Commit.

Now the project is committed to the local git repository.

5.  Now Push the local git  repository to github.com. Right  click on the project and Select Team->Remote->Push

step11

Assume that you have created new remote repository (In our example, JavaRestService)  in github.com. If you have not created, new remote repository, then follow the steps given in the Part II.

6. Paste the remote git repository URL in the URL input box and give  github.com userid and password then select next. In our example, we are using https protocol.

step16

7. Select source and destination reference (refs/heads/master) as given in the image and click on Add Spec then Next and Finish

step17

8. Confirm the push

step18step19

now you have successfully  pushed the local repository to remote github.com

 

Part II) Creating new remote repository in github.com
  1. Login to github.com

step12

2. Click on Create Repository and enter new repository name (In our example: JavaRestService)

step14

step15

3. Confirm the button Create Repository

Now the remote empty repository is created and the  URL for the repository is

https://github.com/vkjegan/JavaRestService

 

PART III) Checking out the github shared project in Eclipse
  1. Right click on Eclipse work space and select Import->Import->Git->Projects from Gitgithub importgithub import1
  2. Select Clone URI and Next

github import2

github eclipse import3

3.  Paste the github.com shared repository url  in the URI  input box(In our example, https://github.com/vkjegan/JavaRestService), fill the user id and password then Next

github eclipse import4

4. Select Branch and Next

github eclipse import5

5. Select local destination directory where the local git repository needs to be created

github eclipse import6

6. Select Next

github eclipse import7

7. Again Select Next and Finish. Now the remote git project is imported and   github repository is created locally.

You may also like

Leave a Reply

Be the First to Comment!