AndroidStudio新建项目推送到码云上
开发一个项目,版本控制工具是必不可少的,常见的有SVN和git等,本人倾向于用git工具。这就需要一个远程仓库,常见有GitHub和oschina。Github的项目私有功能是收费的,而且在国内访问GitHub很慢。Oschina是全免费的,而且国内访问很快,所以选择oschina是个不错的选择。下面就是怎样把你的AndroidStusio项目上传至oschina上。
安装好必要的工具
git安装
AndroidStudio安装配置
Oschina注册和配置
在码云上注册帐号,并且创建一个项目

如果AndroidStudio无法配置Git,需要安装插件:Git Integration 和 GitHub

检测Git是否在AndroidStudio上配置成功

使用AndroidStudio3.1创建项目,然后进行如下操作:

选择版本控制工具:


然后仓库就创建好了,此时左方文件应显示为红色

然后VCS--git--add 代码添加到git仓库

有提示是否将vcs.xml (版本控制的配置文件) 也一并加入到仓库,这个随意。

右上commit changes,提交代码的操作

填写提交信息

然后进行push的操作

定义仓库地址

填写仓库地址

在码云上面复制项目地址

将复制的项目地址填写到,输入框中

点击push进行推送

push推送失败:

VCS--git--pull(看清楚不是push)拉取Readme.md

点击刷新按钮进行刷新的操作

刷新完成后,勾选master,点就pull进行拉取

拉取失败:fatal: refusing to merge unrelated histories(不能合并不同的仓库的提示)

请前往你项目的文件夹

右键 Git Base here.

输入 git pull origin master --allow-unrelated-histories 回车,等待合并拉取到Readme.md,关闭窗口。

拉取成功后如下图,若拉取不成功则反复上一步的操作.
需要将冲突的文件resolve掉 : git add -u

此时项目中多了README.md文件

打开README.md文件进行编辑,然后进行提交

编辑提交修改的内容,然后commit

再次进行提交的操作,push推送

push的内容

内容提交成功:

至此大功告成.
总结:
先更新拉取内容,然后修改拉取的内容,在提交,最后再推送到远程仓库