android studio add an activity to mobile,如何使用 Android Studio 的 github 功能

How to use GitHub with Android Studio

This article will explain how to use GitHub withAndroidStudio.

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

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

Leave the next page as default and clickNext.

bafe5de8c3b9

On theAdd an activity to Mobilescreen selectBlank Activityand clickNext.

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

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 origin https://github.com/[username]/[project_name].git

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

bafe5de8c3b9

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.

bafe5de8c3b9

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.

bafe5de8c3b9

In the next screen, type aCommit Messageand selectCommit.

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

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

bafe5de8c3b9

上述转自:http://blog.csdn.net/ganshuyu/article/details/41965853

还有篇不错的教程:http://blog.csdn.net/gao_chun/article/details/49817229/

注:

1、在  git remote add originhttps://github.com/[username]/xxx.git  连接远程库使可能会报错

fatal: remote origin already exists. ,此时可以先

(1)先删除远程 Git 仓库

$ git remote rm origin

(2)再添加远程 Git 仓库

$git remote add originhttps://github.com/[username]/xxx.git

2、在push时可能报错Push rejected: Push to origin/master was rejected

出现错误的主要原因是github中的README.md文件不在本地代码目录中

bafe5de8c3b9

可以通过如下命令进行代码合并【注:pull=fetch+merge]

git pull --rebase origin master

bafe5de8c3b9

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值