Creating a Git Repository for Android Projects

A beginner’s tutorial for creating a Git Repository in Eclipse using EGit for Android projects

I suggest looking at my EGit tutorial first.

If you haven’t already you will need to sign up for a Git account (

Create the Repository

Login to your Git account

On your main page ( select the Repositories tab

Select New

Enter a name for your Repository

The Repository will have to be Public unless you want to pay for an account. Don’t worry users only get read access unless the creator of the Repo decides to give them write access.

Check the box for Initialize this repository with a README

Click the dropdown to select a .gitignore file. Obviously, you can select any number of options but this is an Android tutorial so select Android.

Select -> Create Repository

You’ve created a bare bones Repo but you still need to add some Android files.

Now you can see and explore your Repo. Make sure that HTTP is grayed out and get the URL next to it. It should be something like

Open Eclipse

Right click the blank space under package explorer

Select -> import

Click the drop down folder for Git

Select -> Projects from Git


Select -> URI


URI: Here you will paste the URL you noted earlier it should follow the format of


Repository path: /user_name_that_created_repo/repo_name.git


User: Your User Name

Password: Your Password


Make sure master is checked


The Directory destination can be wherever you like but make sure the folder is the same name as the Repo name

Leave everything else alone


Select -> Use the New Project wizard


Select -> Android Application Project


Application Name: Should be the same as the Repo (it can be different but I’ve sometimes had problems doing it that way)

Project Name: Same as Application Name

The other options are up to you


Finish the New Android Application wizard the same way you’d do any other project. The other options make no difference on this tutorial.

Once you are finished you will need to edit the .gitignore file.

At the root of your new Application folder in the Package Explorer Pane you should see a .gitignore file (it will be just above the AndroidManifest.xml file). If you don’t see it then you will need to change your Package Explorer Pane settings by clicking the down arrow next to the Package Explorer title -> then select Filters -> then uncheck the .*resources option -> Ok

Now you can open the .gitignore file by double clicking it (to open it in the default text editor) or by dragging the file to the tabs of the Eclipse file viewer (where your .java and .xml files open).

When Git creates the .gitignore file it adds two files that prevent Eclipse from allowing users to Import Existing Android Projects. It causes lots of headaches later so let’s fix it.

Delete the following (and just the following) from the .gitignore file

# Eclipse project files

Save and close .gitignore file

Now you will need to push your files

Right click the folder

Highlight Team

Click Commit

Add a commit message

Check all the files

Click Commit and Push

Once the push has finished you are ready to use the Repo for your android project

Add Collaborators

On your main page ( select the Repositories tab

Select the Repo you want to change

Select the Settings Option on the far right under the Fork counter

Select Collaborators on the left side

Confirm your password (if you need to)

Enter the Git username of the new Collaborator and click Add

Your Collaborator now has write access to your project