Reputation: 2357
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)
Upvotes: 35
Views: 71380
Reputation: 845
Follow these steps
Team
-> Share
Create
-> Browse
if you already have oneUpvotes: 49
Reputation: 1691
An alternative route (I have found the built-in Eclipse tool to be finicky at times):
git init
to create a repositorygit 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)git commit -m "your message here"
to perform your first commitAt this point, you have a brand new local repository containing your files! The following steps will hook it up to a remote repository.
New
button, and follow the prompts.your-repository-name.git
git remote add origin
into your terminal, followed by that HTTPS linkgit 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.
Upvotes: 28