How to use GitHub with Android Studio

Source: Internet
Author: User

How to use GitHub with Android Studio | London App Developer

Update:this is a old tutorial written for Android Studio Beta. Since Then there has been some updates and (although the below would still work), you could find it quicker to follow my upda Ted Tutorial How to the use of GitHub with Android Studio 1.x.

This article would explain how to use GitHub with Android Studio.

Firstly, let's login to github.com and create a new repository. From the top right corner of the screens, 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 would run on" screen

On the Add a 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 would 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 screens, leave it all as default and click OK.

Android Studio "Select directory for git init" screen

Now use Internet Explorer and navigate to the root of your Projects folder. Right-click and select git Bash (If you don't see this option, then first install git for Windows).

When the Git bash screen appears, type:

Git remote add Origin https://github.com/[username]/[project_name].git

An example of a Git repository URL is: https://github.com/markwint/testproject.git

Entering command into Git Bash

Then press ENTER. The GitHub remote is added to your Git repository.

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

Android Studio "Git > Add" option

It would seem like nothing had happened, but trust me, the project files is added.

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

Android Studio "Commit Directory" option

In the next screen, type a commits 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'll see the this message.

Android Studio Successful Git Push

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

GitHub repository pushed from Android Studio

Hope that was helpful.

Comments
  • Messerli Vinzenz says: September at 8:22 am

    Thank sharing This, it really helped me!

    Reply
    • Mark says: September at 6:40 pm

      Great, I ' m glad you found it useful. How is your finding working with the Android Studio so far?

      Reply
  • Prashant Pandey says: October at 5:55 pm

    thank Sir

    Reply
  • Noman says: October at 10:06 am

    Thank you. It works

    Reply
    • Mark says: November 5 at 2:48 pm

      Glad you found it useful!

      Reply
  • AMD says: November at 11:34 am

    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?

    Reply
    • Mark says: December 8 at 5:08 pm

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

      Reply
  • Wrolf says: December 7 at 5:47 pm

    Thank. Just what I needed.

    Reply
    • Mark says: December 8 at 5:07 pm

      That's brilliant, glad you found it helpful

      Reply
  • Piotrek says: December at 8:36 am

    Excellent Article–thank you very much!

    Reply
  • Zeeshan says: January 3 at 12:20 pm

    Thank you much. It works!

    Reply
  • Jess says: January 5 at 1:04 am

    I ' m trying to does this with my own project and it keeps giving me "Push rejected:master:rejected". Any idea why?

    Reply
  • luditetechnologies says: January at 2:15 pm

    Nicely done. I had serious issues with rejections when I am trying from my home and 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?

    Reply
    • Mark says: January at 2:26 pm

      Glad it helped you. Not sure regarding the layout, can-you-send a screenshot to my Email:mark (at) winterbottom.me ...

How to use GitHub with Android Studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.