Android Studio使用github

所需工具

1.github账号  https://github.com

2.git(免费、开源的分布式版本控制系统) https://git-scm.com/downloads/

3.android studio

步骤

安装git

默认选项一路安装到底

git设置

需要设置用户名和用户email,不设置的话在as提交代码时会报“Please tell me who you are”的error

打开cmd,输入:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

以上步骤操作完毕可以查看一下操作结果:


 

AS设置

打开as,file-->settings




 点击test弹出如下画面说明git配置成功:



 
 继续

下图执行到第三步时会让你设置一个Master Password

点击test弹出如下画面表示github配置成功:


 

提交工程至Github

打开你要提交的工程,然后在顶部菜单栏选择VCS-->Import into Version Control-->Share Project on GitHub

如果是第一次提交该项目会出现如下对话框,提示你这是一个新的存储库,可以自定义库名,和添加描述。(以下几幅图来自互联网=。=)



 
 填写完毕点击share,若工程没问题会出现如下界面:



 

这里列出了提交清单,点击ok



 

键入Master Password,戳ok

如果提交成功as右上角会提示相关信息



 

导入github工程

http://blog.csdn.net/j236027367/article/details/48802493

不赘述

<!--成功的分割线--------------------------------------------------------------------------------------------------------->

可能出现的问题

“project is already on GitHub”

把github中的一个repository 删除后,想重新将project分享到github,但是Android Studio Project 依旧提示“ project is already on GitHub ”

解决方法:关闭Android Studio,进入电脑中你要分享的那个项目的目录,假设我这里的项目目录是 C:\Users\yl\AndroidStudioProjects\projectname\,开启“显示隐藏文件”的功能,就能看到隐藏的文件夹.git  ,打开其中的config文件,删除类似于下面格式的代码:

[remote "origin"]

url = https://github.com/gonyulian415/MyFirstApplication.git

fetch = +refs/heads/*:refs/remotes/origin/*

[remote "github"]

url = https://github.com/gonyulian415/MyFirstApplication.git

fetch = +refs/heads/*:refs/remotes/github/*

然后保存,then enjoy it!

“The directory / is under Git, but is not registered in the Settings”

这是as从github导入工程时会出现的问题,解决方案:

选中unregistered roots,点击右边+号



 

猜你喜欢

转载自gonyulian415.iteye.com/blog/2317854