It's been at least two years since I started a new Android SDK project and since then I've become rusty at setting one up correctly with GitHub. My usual work-flow on a web project is to create the repository in GitHub with a basic README and ignore file, clone to my local machine, and start development. However, creating a project in the Android SDK generates lots of files and directories that need to be part of the repository. Therefore, it isn't quite as straight-forward to just clone and start development.
If you are starting a new project, the easiest way to get your project sync'd up with your GitHub repository is to start with a new repository in GitHub, create an Android project in SDK, then connect your local repository to the one in GitHub,
The first step is to create a new repository in GitHub. Go to your GitHub account, click on 'New Repository', choose a repository name, and make sure that the checkbox to automatically add a README file is checked. Also, make sure add a .gitignore for Android. After the repository is created, take note of the SSH URL to your repository. I created a repository named 'android-test' and my SSH URL was 'firstname.lastname@example.org:jonstjohn/android-test2.git'. We'll use that shortly to connect our local repository with the one on GitHub.
After the repository is setup in GitHub, you will want to create a new Android Project in the SDK. To create a new project, click on File -> New -> Android Application Project. Follow the dialog windows until the project is created in your Eclipse workspace.
Next, you will initialize your local repository and connect it to your remote one. On my Windows machine, I have Git installed with the windows explorer integration, so I can just navigate to my Android project in windows explorer, right-click and choose 'Git Bash'. That gives me a nice command prompt to initialize the repository with. On my Mac, this is much easier as I can just use the standard command prompt and navigate to my project directory.
Once you are in the project directory, run the following commands:
git init git remote add origin email@example.com:jonstjohn/android-test.git git pull origin master git add . git commit -m "first android project commit" git push -u origin master
The first line 'git init' initializes the local repository. The second line 'git remote add origin' connects your local repository with the one on GitHub. Next, you can pull the README.md and .gitignore files using 'git pull origin master' and sync'ing the two repositories. Next, 'git add .' and 'git commit' add your files and commit then to your local repository, and 'git push' pushes it to the repository on GitHub.
You will now have your local working repository connected to your GitHub repository and can continue developing and pushing changes to GitHub.
I've recently started using the GitHub Window Clients and the GitHub Mac Client which simplify the workflow, particularly on Windows. If you choose to use those clients and can't seem to find the repository that you just setup, try going to Tools -> Options -> Scan for Repositories. It should appear, click 'Add', and you are good to go.