关于 git和github在这里就不做介绍了
准备工作
其实也没什么要准备的,主要就是安装git版本控制系统,android studio 和在github上面注册一个账号
上传新建项目到github步骤
一、android studio的git配置
打开android studio 打开如下路径File->Settings->Version Control->git(或按快捷键alt + ctrl + s到设置页面)
点击test按钮如果出现 Git executed successfully 对话框说明配置成功,同时对话框会显示你安装的git版本号;如下图所示
二、配置github登录信息
打开android studio 打开如下路径File->Settings->Version Control->Github(或按快捷键alt + ctrl + s到设置页面),如下图所示
Password:就是github密码
填完之后点击test按钮,如果出现如下对话框说明配置成功
三、上传工程到github上
打开你要上传的工程,顶部菜单选择VCS->Import into Version Control->Share Project on GitHub,如下图所示
如果你是第一次提交该项目会出现如下两个对话框对话框,第一个提示输入你的Master password,第二个提示你这是一个新的存储库(repo),可以自定义repo的名字,和添加描述。
填写完毕点击share按钮如果你的工程没有问题会出现如下界面
点击ok,如果提交成功studio右上角会提示相关信息
此时打开你的github网站地址在你的repositories中会看到刚刚提交过的工程名称,点击进去会看到完整的提交工程,到此提交结束
项目更新
一、如果你的项目新增了一个类,当你创建该类的时候会提示你是否需要加入git,如下图所示
选择yes该类就会加入git,同时该类本身的颜色会有改变
此时该类右击->Git->COmmit File… 出现如下对话框
填写 commit message 后点击Commit按钮,有可能会出现如下警告,忽略它点击Commit
再次右击->Git->Repository->Push,如下图所示
点击Push出现如下对话框,点击Pust按钮
此时打开你的github上的该项目源码,你会发现新增的类已经出现了
二、如果你的项目中某个类进行了修改需要重新提交
右击该类->Git-Add
这步其实是把该类加入到git中,后面的步骤和新增类的操作一样,这里不再赘述。