How do I add existing eclipse java project to git
Solution 1
An alternative route (I have found the built-in Eclipse tool to be finicky at times):
- Open up your terminal
- Navigate to your project directory
- Type
git init
to create a repository - 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 usegit add filename
to add only specific files/folders) - 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.
- Create your remote repository (using GitHub as an example, simply click the
New
button, and follow the prompts. - Open up your terminal and navigate to your project directory
- On the page for your repository, you should see an HTTPS link ending in
your-repository-name.git
- Paste
git remote add origin
into your terminal, followed by that HTTPS link - 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
- Right click on the project
- Select
Team
->Share
- You will be prompted to select the tool you prefer
- Click
Create
->Browse
if you already have one - Select git and go on
![dmeehan](https://i.stack.imgur.com/B5NLL.png?s=256&g=1)
dmeehan
using System; namespace HelloWorld { class Hello { static void Main() { Console.WriteLine("Hello World!"); } } } `
Updated on May 02, 2020Comments
-
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)