Android Studio中使用Git进行代码管理(分支、合并
原文地址 Android Studio中使用Git进行代码管理(分支、合并)
打开Android Studio选择,选择从Git检出代码

也可以从VCS如下点击

去远程仓库复制地址,这里以码云Gitee第三方代码托管为例,类似Github的界面,点击右边复制项目地址

填一下配置,点击Clone开始检出代码

一直点OK即可

不一会儿代码就检出成功并打开

接下来我们来打个分支,命名为V1,右击项目--Git--Repository--Branches...

也可以从VCS这样点击

可以看到,项目目前就一个Master分支

点击New Branch新建分支,输入分支名V1,点击OK

看到分支V1创建成功

右击项目--Git--Repository--Branches...可以看到本地分支多了个V1分支

创建一个V1.java文件,便于区分分支

点击Commit+Push上传到远程仓库

提示上传成功

我们去码云远程仓库看一下,可以发现V1上传成功了

接下来我们把V1合并到Master主分支,右击项目--Git--Repository--Branches...--master--Checkout检出master分支(即切换到master分支)

发现V1.java文件不见了,说明分支切换成功

然后 右击项目--Git--Repository--Branches...--V1--Merge合并分支

提示合并成功

因为合并是在本地操作的,所以我们还需要push到远程,点击Commit+Push


如果提示

随便改动一下文件再提交就可以了

提示Push成功,我们去码云看一下Master分支下有V1.java,说明分支合并成功了,两个分支的文件相同,Perfact !!!


可通过以下途径关注本人:
Githubhttps://github.com/Zachary46
CSDN博客https://blog.csdn.net/Zachary_46
博客园https://www.cnblogs.com/Zachary46