Search code examples
javaeclipsegithublibgdx

Uploading local gradle project to GitHub repository


I'm fairly new to github so this might be a very simple issue. I have been working on a basic game using libGDX. I used the gdx setup tool to create the gradle project and I have since been developing locally. All I wanted was to upload my code to github so I could share code more easily, but I have never done so through eclipse.

I went on github and created a new repository. Then I cloned the repository and attempted to commit and push my project. However, the gdx setup tool actually created three projects: core, desktop, and a gradle project. I wasn't sure what to do so I pushed each project independently to the repository. core and desktop only contained .project. The gradle project contained all the class files that were originally within core and desktop, so I deleted core and desktop from the repository.

Now when I import the repository into eclipse, all my class files are there and there are no errors but run as shows that there are no applications to run my code. How can I somehow salvage this code so that I can run it and then properly upload it to a github repository?


Solution

  • When I talk about directories below, I mean the ones in your file system, not the way projects are arranged in the Project Explorer view in Eclipse.

    You should create a single repository using the directory that contains all the modules (core, desktop, etc.). Use git init from the command line in your base directory. Then do your initial commit of all your files. Keep your command line window open.

    Then create a new repository on Github. Don't select to initialize it with a README file. On the next screen, in the section "…or push an existing repository from the command line" it will have code you can copy and paste into your command line window to do your initial push to Github and set the Github repo as the remote origin that is tracked.

    It is probably easiest if you delete the Github repo and local repo(s) you already created and start over. You can delete the local repos by deleting the .git directory.