Search code examples
eclipsegithubclone

Cloning a github repo into an existing project?


I have a project in Eclipse that I want to put on github, so I went to github and created the repos for them, but I want to clone them right into the folder where the files are stored in my eclipse workspace. How can I do this?

EDIT: When I try it, the github app says it can't clone because the folder isn't empty.

EDIT 2: Will this work? Changing the name in eclipse to rename the project folder, then cloning the repo to the name I want, in the workspace, then renaming the eclipse project so they merge and I can commit the new files.


Solution

  • GitHub has a guide explaining how to put an existing project on GitHub.

    You should not clone the repository, but add the GitHub repository as a remote to a local repository you create yourself.

    1. Go to your project folder and initialize a local repository with git init
    2. Add and commit all your project files to the local repository. (e.g. git add . and git commit -m "message")
    3. Add the GitHub repository as a remote. git remote add origin *github repository URL* (Verify with git remote -v)
    4. Push your project to GitHub with git push origin master.

    If you already have committed files to the GitHub repository, it is still possible.

    1. Initialize your local repository.
    2. Add GitHub as the remote.
    3. Pull from GitHub.
    4. Add and commit your project.
    5. Push you project to GitHub