Github and Android Studio software logos on a yellow background image

This article provides a basic overview of how to use GitHub with Android Studio. 

Video Demonstration

Firstly, let’s login to and create a new repository. From the top right corner of the screen, click the + sign and select New repository.

GitHub "New repository" option

Now complete the form to create a new repository called testproject. Leave the Initialize this repository with a README unticked.

GitHub create new repository form

Next, open Android Studio and create a new project. Call your new application TestProject. Click Next to continue.

Android Studio new project window

Leave the next page as default and click Next.

Android Studio "Select the form factors your app will run on" screen

On the Add an activity to Mobile screen select Blank Activity and click Next.

Android Studio "Add an activity to Mobile" screen

In the next screen, leave the default activity name of MyActivity and click Finish.

Android Studio "New file options" screen

Your new project will open in Android Studio. On the top menu, select VCS > Import into Version Control > Create Git Repository.

Android Studio "Create Git Repository" option.

On the next screen, leave it all as default and click OK.

Android Studio "Select directory for git init" screen

Now use Windows Explorer and navigate to the root of your projects folder. Right click and select Git Bash (If you do not see this option, then first install Git for Windows).

When the Git bash screen appears, type:

git remote add origin[username]/[project_name].git

An example of a Git repository URL is:

Entering command into Git Bash

Then press enter. The GitHub remote will be added to your Git repository.

Next, jump back into Android Studio, right click your projects root directory and select Git > Add. This will add all your project files to your Git repository.

Android Studio "Git > Add" option

It will seem like nothing has happened, but trust me, the project files are added.

Now right click the project name again and this time select Git > Commit Directory.

Android Studio "Commit Directory" option

In the next screen, type a Commit Message and select Commit.

Android Studio "Commit Changes" option

If a Code Analysis warning appears, click Commit. (Unless it’s a real project, in which case review and fix the issue before committing!)

Android Studio "Code Analysis" warning

Now, right click the project name, select Git > Repository > Push.

Android Studio "Git Push" option

Check the box Push current branch to alternative branch and leave the branch name as master. Then select push.

Android Studio "Git Push" prompt

Now enter your GitHub Login (email address) and Password. Then click OK.

Android Studio GitHub Remote Login

If it’s all good, you will see this message.

Android Studio Successful Git Push

Now your code is pushed to your GitHub repository. Don’t believe me? Logon and check for yourself.

GitHub repository pushed from Android Studio

And that’s it! I hope you found this post helpful? Let me know in the comments below.


123 replies
      • Vipul
        Vipul says:

        Android Studio is really horrible to work with. Eclipse was the way we were doing Android, but they deliberately broke Eclipse.

        • Adam
          Adam says:

          bro you responded 4 years later and if you have a decent computer android studio is definitively better than eclipse. especially in 2018. no clue what you’re going on about

  1. amd
    amd says:

    I may have entered a wrong password, it says “Push Rejected”. The enter password popup is not showing again. How can I re-enter my password?

    • mark
      mark says:

      Hi amd. Did you try to close Android Studio and re-open? This comment is a bit old so did you figure the solution already? If not, let me know.

  2. Jess
    Jess says:

    I’m trying to do this with my own project and it keeps giving me “Push rejected: master: rejected”. Any idea why?

  3. LuditeTechnologies
    LuditeTechnologies says:

    Nicely done. I had serious issues with rejections when I was trying from my home but I tried this tutorial again from my office with a different project and it worked flawlessly.

    I have one question: My final layout ( the project tree structure, I mean ) looks slightly different from your screenshot at the end. Does that matter at all?

  4. Nilesh
    Nilesh says:

    Very good tutorial with screenshots, I was stuck on “Nothing to push” message while pushing to github, you advice to Check the box Push current branch to alternative branch before pushing helped me a lot.

    Thanks again.

  5. Saifur Rahman Mohsin
    Saifur Rahman Mohsin says:

    Great article. I have a query, I wonder if you are aware of the answer to this. In the Android Studio “Commit Changes” option image in this blog the author field is empty, clicking on the dropdown shows my name and I select it every commit. Is there a way to set my name as default so that it automatically fills in when I goto VCS -> Commit Changes?

  6. Tuhin Das
    Tuhin Das says:

    Android Studio keeps on saying “Push to origin/master Rejected” I have no idea why and I have to submit some Android code soon.. to a tutorial.. please help

  7. Moustafa
    Moustafa says:


    Why I don’t have that option in my Android Studio?

    “the check box Push current branch to alternative branch”

    Thank you.

  8. harin kaklotar
    harin kaklotar says:

    I got error when I push
    Failed with error: fatal: unable to access ‘’: Failed to connect to port 8087: Connection refused

    • mark
      mark says:

      Hi Harin. That is strange. It looks like is resolving to for you. In command prompt can you try and ping and see what IP address it resolves?

  9. Shilpa
    Shilpa says:


    I tried the steps you mentioned above and they were really helpful. I am facing a problem with Github 2 factor authentication, which does not allow me to login through android studio. Any idea how to resolve this ?


    • mark
      mark says:

      Hi Shilpa. Great question. I just enabled Two Factor auth to test this myself. You are correct, Android Studio does not support GitHub Two Factor authentication. You can get round this pretty easily by using the GitHub private key authentication to clone your repository, and then open the repository in Android Studio.

      Let me know if this works for you or if you need more details.

  10. Omar kwydi
    Omar kwydi says:

    when I run my application by Android Virtual Devices (AVDs)
    I have problem

    there are Error message ” this AVD’s Configuration is Missing a kernal File ”

    I am waiting the Replying from Your And thank you on your Subject

    • mark
      mark says:

      Hi Omar. That sounds like a problem with your Android Studio or Android SDK installation.

      I would need more details to figure out exactly what the issue is. My suggestion would be to re-install Android Studio and the Android SDK completely.

  11. Sayom
    Sayom says:

    Hello Mark,
    Thanks for the post. I have been able to create the GitHub repository for the project present in the Andriod studio located in my local machine. Your blog is wonderful. I have one query into it. I would be requiring the outputs folder content to be pushed into the GitHub as well, so can you let me know how to do it, as when I push the code currently, the output folder is not going into the Github.

    • mark
      mark says:

      Hi Sayom, thanks for the comment and kind words about my blog. Did you try going to ‘VCS > Git > Add’ and ensuring the ‘output’ folder is added? If it doesn’t work, open your .gitignore folder and check that ‘outputs’ isn’t added to .gitignore.

  12. Nandha
    Nandha says:

    After following all your steps Push commits shows that ‘master -> Empty repository’. Will you help in this, i am using Android Studio 1.5.1

  13. Patrik
    Patrik says:

    Nice! Works with AndroidStudio 2.0 as well!!
    Only differenc is if you want to commit to different branch, leave the checkmark emty. It is has the oposit meaning in android 2.0.

    Thank You! I have no experience with eather Android studio or Git started googleing and found your tutorial fiirst thing probably saved me a couple of DAYS!! 😀 😀

  14. someone
    someone says:

    Thank you so much! It works.
    The only problem is that my Github account has 2-step verification, so I encountered some trouble, fortunately I solved it.

    • mark
      mark says:

      Hi Sam, it sounds like the git repository hasn’t been initialized? Did you click “Create Git Repository”?

  15. David
    David says:

    Nice video! is there a follow-up to it? maybe something explaining how a different user then checks out the repository?

  16. Ranvir
    Ranvir says:

    That was awesome …point of correction not internet explorer its window explorer.Great job again and again now about to google on how to check out through git hub.It is useful information that i need this..
    Thanks for sharing this information to all……

  17. m
    m says:

    thats not the default, its where ever you were last, so i add drawable. change the instructions to ensure pointing to the right place

  18. Nitin
    Nitin says:

    Thanks a lot mark, a great direction for the newbi user of android studio who want to switch from eclipse.

    Thanks once again

  19. Ben
    Ben says:

    Seemed to be working fine but on the final step (pushing the files) I get an error message that says:

    Push failed: Failed with error: fatal: repository ‘’ not found

    Please would you be able to help?

  20. pritz
    pritz says:

    Man ,can you tell me how to use git from two android studio to work on a same project and make changes from two systems.what all steps are there for doing that.

    • mark
      mark says:

      Hi Pritz, assuming you already have the project on one computer, you would push to GitHub using the instructions on this post, and then on the second computer you would clone it. Then when you make a change on either one, you push the changes and then on the other machine you pull the changes. Does that make sense?

  21. pritz
    pritz says:

    Yeah man ,i am convinced with your answer but i want more deep information about this thing…
    As we are working on the firebase app so.. in order to fully access the codes privilege from the 2 devices(me and my team partner).. what are the things we need to set up..

  22. Aritra
    Aritra says:

    pushing ins’t a success cause i get the error ” Failed with error: fatal: unable to access ‘’: Unknown SSL protocol error in connection to ” .please help

    • mark
      mark says:

      It will be recognised by Git which Android Studio will use so the answer is yes. Although note that if you have already added the files to Git before you set the .gitignore then you will need to remove them from git manually.

  23. Mai
    Mai says:

    Not sure what happened, but I followed the steps and ended up having several errors in my code whereas before the code was fine.

  24. Steve Roylat
    Steve Roylat says:

    Hey Mark, I needed to execute ‘git init’ before I could add remote add the repository to Github. I’m not sure if this is to do with the way I went about adding my project to git. It’s a pre-existing Android project, and the project name is different to that of the repository. I had to call git init just after selecting ‘Creating Git Repository’ in Android Studio.

  25. Mahar Sheraz
    Mahar Sheraz says:

    Thanks,good work and it helped me a lot..
    now i wanted to ask that how can we import complete project from GitHub into Android Studio with gradle build and repositries..

    Looking forward for your reply…..Thanks

  26. sanjeev
    sanjeev says:

    thanks for ur good work and it helped me a lot..but i am getting this error while sharing android project through different gmail account than previous one.error::”Can’t connect to repository from configured remote. You could want to check .git config.Do you want to proceed anyway?”.project is already on github

  27. Sushant Chaturvedi
    Sushant Chaturvedi says:

    Thank you for sharing this, it really helped me! thanks again

    but I found this error when i was ready to push

    Push failed
    Failed with error: fatal: The remote end hung up unexpectedly
    fatal: The remote end hung up unexpectedly
    error: RPC failed; curl 56 SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054

  28. Cara
    Cara says:

    Thanks for the tutorial and it’s really helpful. However when I did it, my git directory cannot find all the java files. My .gitignore looks fine and there’s no .git in the java file directory. Do you happen to know what may cause this? Thanks in advance.

  29. Ram Prasad Gudiwada
    Ram Prasad Gudiwada says:

    can not run git.exe : Create process error=2, The system cannot find the file specified
    This error is coming
    when I click on Share on GitHub

  30. Rashedul Hasan
    Rashedul Hasan says:

    Hello Mark,
    I have been using these instructions to add android studio projects to Github and worked fine. But now when I have added one project to github from one pc and then copied the files to another pc using pendrive – it was showing error when adding to github in another account(error: project already exists in git). So, i deleted the .git directory and tried to add it from the beginning. everything was successful but at the last stage when i pushed the files from android studio, it shows error: (Failed with error: fatal: unable to access ‘’: The requested URL returned error: 403). Can you give a solution?

  31. Rajesh Samson
    Rajesh Samson says:

    Thanks for this wonderful tutorial. I have a question for you in case we want to ignore the target classes or the generated classes how can we ignore them while pushing the code.

    Thanks in advance


Trackbacks & Pingbacks

  1. […] also decided to take a minute and figure out the right way to upload projects from Android Studio to GitHub. I want that to develop into a habit that I don’t have to think about. I think I’ve […]

  2. […] we have enough playing. Time for something more serious. Go to and follow the steps bit by bit. Of course, this is assumed that you have already installed github […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.