How do I add existing eclipse java project to git

55,684

Solution 1

An alternative route (I have found the built-in Eclipse tool to be finicky at times):

  1. Open up your terminal
  2. Navigate to your project directory
  3. Type git init to create a repository
  4. Assuming you already have files in that folder, type git add --all to add all your files to the repository (Note: if you skip this step, you will have an empty repository. You can also use git add filename to add only specific files/folders)
  5. Type git commit -m "your message here" to perform your first commit

At this point, you have a brand new local repository containing your files! The following steps will hook it up to a remote repository.

  1. Create your remote repository (using GitHub as an example, simply click the New button, and follow the prompts.
  2. Open up your terminal and navigate to your project directory
  3. On the page for your repository, you should see an HTTPS link ending in your-repository-name.git
  4. Paste git remote add origin into your terminal, followed by that HTTPS link
  5. Paste git push -u origin master into your terminal (Note: these last two steps are shown on the GitHub new project page as well, for easy copy-and-pasting into your terminal)

Now you have a local repository connected to a remote repository, ready to use! All Eclipse projects exist somewhere in your file system, and can easily be accessed just like any other folder you might want to turn into a repository.

I do realize you asked to avoid the command line, but this is a relatively simple command line task, and learning to be somewhat familiar with how to use your command line can pay big dividends later on.

Solution 2

Follow these steps

  1. Right click on the project
  2. Select Team -> Share
  3. You will be prompted to select the tool you prefer
  4. Click Create -> Browseif you already have one
  5. Select git and go on
Share:
55,684
dmeehan
Author by

dmeehan

using System; namespace HelloWorld { class Hello { static void Main() { Console.WriteLine("Hello World!"); } } } `

Updated on May 02, 2020

Comments

  • dmeehan
    dmeehan about 4 years

    How do I add an existing java project in eclipse to git?

    I noticed when creating the project there was an option to add to source control but I can't find this option for an existing project. Is this possible from the git plugin in eclipse or must it be done from the command line? (I am using a Mac)