如何在Android Studio上使用Github
首先,登陆到Github上并创建一个新repository。在屏幕右上角,点击“+”标记,并且选择“New repository”。

现在完成这个表格以新建一个叫做testproject的新repository,让这个repository自动初始化并带上REDEME文件。
接下来,打开Android Studio并且创建一个名为TestProject的新项目,点击“Next”进行下一步。


下一页直接设为默认,并且继续点击“Next”。

.


你的项目已经出现在Android Studio上,在顶部标题栏里,选择VCS > Import into Version Control >Create Git Repository。

在下一页里,保持默认,点击“Ok”。
Android Studio “Select

现在使用Windows的资源管理器导航到该项目的根目录。右键单击并选择Git Bash(如果你没有这个选项,那么首先需要安装 Git for Windows)。
当Git bash界面出来时,输入:
1git remote add origin https://github.com/[username]/[project_name].git
作为一个例子,此处Git repository的URL为: https://github.com/markwint/testproject.git

然后按Enter,Github将会远程添加到你的Git repository。
返回Android Studio,邮件单击你的项目根目录,并选择Git > Add。它将会添加你所有的项目文件到你的Git repository。
Add option width=538 height=518 scale=1.5 /> Android Studio “Git > Add” option

看上去并没有发生什么(译者也没看到异样),但是相信我,项目文件已经添加了。
现在再次右击项目名称,并且这一次选择Git > Commit Directory。

在下一页中,输入Commit Message并且选择“Commit”。

如果代码分析警告出现了,点击“Commit”。(除非这是一个实际的项目,在这种情况下就得审查并且在提交之前解决这个问题!)

现在,右击项目名称,选择 Git > Repository > Push。

检查框中当前分支,离开主分支名称,然后选择推送。

现在输入你的Github Login(Email地址)和Password,然后点击“Ok”。

如果这些都没问题,那么你将看到这条消息。

现在你的代码已经推送到你的Github repository了。不相信我?登陆并检查看看吧。(老外此处把Login写成了Logon,看来并不是我们才会写错字嘛。)
希望这个有用吧。


网友评论