21

I am successfully pushing my project to GitHub using EGit. My repository is called HelloWorld. My project in eclipse is also called HelloWorld. My problem is when i push the project it is upload the project under the folder HelloWorld. So the result is the repository HelloWorld then the folder HelloWorld and the the src folder. To be more understandable here is the link of the project. I want under the repository HelloWorld to have the src folder. How can I achieve that?

salvador
  • 1,079
  • 3
  • 14
  • 28
  • 1
    @KumarAbishek, To get URI, go to your GitHub account, open the corresponding repository and copy the current page url. Once you paste the url in URI field, other fields such as Host, Repository path and Protocol will be auto populated. – Ashok Pandian Jan 25 '17 at 09:47

5 Answers5

34

The key lies in when you create the project in eclipse.

First step, you create the Java project in eclipse. Right click on the project and choose Team > Share>Git.

In the Configure Git Repository dialog, ensure that you select the option to create the Repository in the parent folder of the project.. enter image description here Then you can push to github.

N.B: Eclipse will give you a warning about putting git repositories in your workspace. So when you create your project, set your project directory outside the default workspace.

greenkode
  • 4,001
  • 1
  • 26
  • 29
  • Hey, i have created a project and shared it with Team > Share>Git. but how can i add new class which added after share with git? how do i update the project on git with this new class ? – 2Big2BeSmall Oct 02 '15 at 11:07
  • 2
    I would suggest you spend some time familiarizing yourself with Git. Here's the Egit User guide, it contains everything you need to know when using Egit from within eclipse. https://wiki.eclipse.org/EGit/User_Guide – greenkode Oct 05 '15 at 07:24
  • see also: http://stackoverflow.com/questions/17552457/how-do-i-upload-eclipse-projects-to-github – TmTron Dec 16 '16 at 16:52
7

Simple Steps:

-Open Eclipse.

  • Select Project which you want to push on github->rightclick.
  • select Team->share Project->Git->Create repository->finish.(it will ask to login in Git account(popup).
  • Right click again to Project->Team->commit. you are done
Satya Tiwari
  • 103
  • 1
  • 2
  • 10
    Satya, Please also mention how to provide URI, Host,Repository path. the one that you are suggesting only works when git project is already configured. – Kumar Abhishek Dec 28 '16 at 10:39
  • Does this take care of dependencies on other projects in the workspace? What would be the best way to handle dependencies? I am trying to get my stuff on Maven to make it easier, but it is slow. – Al G Johnston Apr 28 '20 at 22:59
1

I use these Simple Steps when I already have committed locally a new project:

  1. Open github.com and sign in and create a new repository.
  2. Copy URL of the new repository.
  3. Open Eclipse.
  4. Select Project which you want to push on github->rightclick.
  5. select Team->share Project->Git-> "push branch '' ...".
  6. Follow the wizard until it finishes.
Shadyar
  • 709
  • 8
  • 16
0

I have the same issue and solved it by reading this post, while solving it, I hitted a problem: auth failed.

And I finally solved it by using a ssh key way to authorize myself. I found the EGit offical guide very useful and I configured the ssh way successfully by refer to the Eclipse SSH Configuration section in the link provided.

Hope it helps.

ZhaoGang
  • 4,491
  • 1
  • 27
  • 39
0

If you ever face an authentication issue in any IDE - Eclipse, sts, etc. Simply while creating a remote repository select ssh protocol it won't ask you any username or password. (But will create a file ed25519 on your system which will be having an ssh key). Now you can push or do other activities using IDE without having any authentication issues.

In case of Git bash use command $ssh-keygen (ask for file give proper file path) suppose you give name as y.pub. Run the command $cat y.pub copy the ssh key(starting something as ssh-rsa...) and paste in GitHub(opened in browser your remote repository) now type command $ssh -t git@github.com If you get an error while using the above command changed the command to $ssh-keygen -t ed25519 -c "your userid" then open the file by using $cat ed25519.pub file copy the ssh key & paste into Github. Now you are authenticated to perform the various operations. The other option if you want to use https only is to generate pat(personal access token).go to github-go to settings-go to developer settings-go to personal access token.If you aready had token delete it else click on generate new token.Give anything in note.Click on repo (you can select multiple options too) click generate token.Copy the token and now in your ide instead of password use the token.I hope it will solve your problem.

S J
  • 1
  • 2