How to use GitHub with Android Studio

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

Firstly, let’s login togithub.comand create a new repository. From the top right corner of the screen, click the+sign and selectNew repository.

如何使用 Android Studio 的 git hub 功能_第1张图片

Now complete the form to create a new repository calledtestproject. Leave theInitialize this repository with a READMEunticked.

如何使用 Android Studio 的 git hub 功能_第2张图片

Next, openAndroid Studioand create a new project. Call your new applicationTestProject. ClickNextto continue.

如何使用 Android Studio 的 git hub 功能_第3张图片

Leave the next page as defaultand clickNext.

如何使用 Android Studio 的 git hub 功能_第4张图片

On theAdd an activity to Mobilescreen selectBlank Activityand clickNext.

如何使用 Android Studio 的 git hub 功能_第5张图片

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

如何使用 Android Studio 的 git hub 功能_第6张图片

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

如何使用 Android Studio 的 git hub 功能_第7张图片

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

如何使用 Android Studio 的 git hub 功能_第8张图片

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

When the Git bash screen appears, type:

1 git remote add originhttps: //github .com/[username]/[project_name].git

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

如何使用 Android Studio 的 git hub 功能_第9张图片

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 selectGit>Add. This will add all your project files to your Git repository.

如何使用 Android Studio 的 git hub 功能_第10张图片

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 selectGit>Commit Directory.

如何使用 Android Studio 的 git hub 功能_第11张图片

In the next screen, type aCommit Messageand selectCommit.

如何使用 Android Studio 的 git hub 功能_第12张图片

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

如何使用 Android Studio 的 git hub 功能_第13张图片

Now, right click the project name, selectGit>Repository>Push.

如何使用 Android Studio 的 git hub 功能_第14张图片

Check the boxPush current branch to alternative branchand leave the branch name asmaster. Then selectpush.

如何使用 Android Studio 的 git hub 功能_第15张图片

Now enter your GitHubLogin(email address)andPassword. Then clickOK.

如何使用 Android Studio 的 git hub 功能_第16张图片

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.

如何使用 Android Studio 的 git hub 功能_第17张图片

Hope that was helpful.

更多相关文章

  1. Android图片圆角
  2. Android 循环读取名字相似的图片
  3. android加载大图片
  4. 扩展Android框架功能和底层模块的技术要点
  5. Android之Glide(非常好用的图片加载框架)
  6. Android加载Gif图片的一般方法:Movie实现
  7. Android九宫格图片(9.png)的讲解与制作
  8. android通过辅助功能收集数据
  9. android如何实现类似ios点击状态栏回到顶部功能

随机推荐

  1. Android(安卓)组件系列-----Activity的传
  2. android button的美化
  3. Robolectric使用(一)简单使用
  4. 第一个变化———由support库到Androidx
  5. EditText焦点控制及软键盘的隐藏显示
  6. BLE 扫描及连接 android程序开发(一)
  7. 活用Android的Message Queue(1)
  8. ANDROID JNI的使用简介
  9. Android照相机应用
  10. 在官网途径无法下载到android 源码时,,你可