Android Studio中利用git进行协同开发
文章目录
下载git
首先需要下载git
下载成功后在电脑打开终端 输入命令git -v
验证

配置账号

在setting中搜索github 登录github账号
推送本地项目
还没推送时是VCS 找一下就行



点击share 会自动在github创建私有仓库

推送
应用场景:自己本地开发好代码,需要推送至仓库中
主要思路:先Update
后Commit and Push
可以看到现在仓库中还是什么都没有的

本地写一个注释

先更新


推送


更新成功

拉取
应用场景:开发伙伴写好之后,自己醒来需要继续开动了,把仓库中的代码更新到本地
先直接在github修改一下 假装是开发伙伴的更新


直接点fetch其实是成功了,但是你看不到,是因为当前还是在本地的master分支,这是对你本地开发的一种保护,避免本地数据丢失
切换到远程的master分支,就可以看到伙伴们改的内容了


网络连接问题
如果推送至github会有网络延迟问题,如果本地有代理,看好端口
unable to access 'https://github.com/happy-Superman/NotepadAndroid.git/': Recv failure: Connection was reset
设置本地代理服务器

然后在终端执行git命令
git config --global http.proxy http://127.0.0.1:1080
查看

想清除设置也简单
git config --global --unset http.proxy