35

I have created a Git Repository on bitbucket. The repository is empty now. I have an Eclipse project, in my system, that I want to push(using Eclipse - EGit) into the repository I created. How do I do it?

I have no knowledge of doing this by command line, so, please, give me the details for doing this by using the GUI of Eclipse. Any links that might help, also are appreciated.

jchanger
  • 739
  • 10
  • 29
Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149

3 Answers3

71
  1. First, make sure you already installed EGit or other git control plugins on your Eclipse.

  2. Second, add Git Source Control to your existing Android Eclipse Project (local) and create a local Git Repository for the Project, by following the steps below: (or check this video)

    • right click your project -> Team -> share project
    • check the option of "Use or create repository in parent folder of project"
    • select your project
    • click the button of "create repository"
    • hit "finish"
    • right click your project -> Team -> Add to Index
    • right click your project -> Team -> commit
  3. Then push your Project (now is under local Git Source Control) to a Remote Repository such as GitHub.com or BitBucket.org, by following the steps below: (or check this video)

    • right click your project -> Team -> remote -> push
    • type in the URL of the remote repository you are using
    • type in username and password, then hit "next"
    • click the button of "Add All Branches Spec"
    • click "next"
    • click "finish"
Corona Luo
  • 731
  • 1
  • 5
  • 5
  • 2
    When I choose my project I get Creation of repositories in the Eclipse workspace is not recommended – Dejell Dec 07 '14 at 10:39
  • 2
    Work perfectly fine. Just in case you get a error unable to push to branch. Make sure to check "Force push or force push into branch" I got this error because I had a README file on my repository upon creation. – jcdevilleres Sep 09 '19 at 05:02
16

Okie.. So I figured it out.

Steps :

  1. First, create a new workspace.
  2. Open that workspace in eclipse.
  3. Go to New->Other->Git->Git Repository
  4. Browse to the Workspace, you just created. Follow the steps in dialog and finish it.
  5. Copy, your existing code, (src, res, etc.,) into the project folder.
  6. Import the project into workspace, File->Import->General->Existing projects into workspace.
  7. Once the application builds, you will have NO HEAD beside the project.
  8. Right click on the project folder, Go to Team->Commit
  9. Enter Commit Message and do Commit And Push. This will take you to screen that asks for URI in bitbucket.
  10. Copy the clone path from bitbucket and paste in the URI path and complete the steps in the dialog. (If you get to a screen asking for Add Specs headers or similar, select the master for Add/Update header and click on button that says Add all specs and finish it.)

Thats it.

Note ::: I am not yet that comfortable with Git, so, probably, the steps may or may not be the correct way or the easiest way to do it. But, that said, these steps worked for me. They might work for you too.

Hope this helps..

Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149
0
  1. Create a git project in eclipse by cloning it from a repository link.

  2. Then open a project location on your drive. Usually C:/Users/yourname/projectname. If you don't know where it is, it says under a working tree in eclipse.

  3. Copy your files/folders there and refresh the project in eclipse.

Notoc
  • 163
  • 2
  • 10