打开Android Studio选择,选择从Git检出代码
![](https://upload-images.jianshu.io/upload_images/6544996-423f687449ace331.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
也可以从VCS如下点击
![](https://upload-images.jianshu.io/upload_images/6544996-4a500a6b59441b8f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
去远程仓库复制地址,这里以码云Gitee第三方代码托管为例,类似Github的界面,点击右边复制项目地址
![](https://upload-images.jianshu.io/upload_images/6544996-6b399efdff40a3be.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
填一下配置,点击Clone开始检出代码
![](https://upload-images.jianshu.io/upload_images/6544996-f4610612925d8d78.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
一直点OK即可
![](https://upload-images.jianshu.io/upload_images/6544996-7ce5f392455482af.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
不一会儿代码就检出成功并打开
![](https://upload-images.jianshu.io/upload_images/6544996-d8fa5ffa3af29275.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
接下来我们来打个分支,命名为V1,右击项目--Git--Repository--Branches...
![](https://upload-images.jianshu.io/upload_images/6544996-31c8901764b6e306.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
也可以从VCS这样点击
![](https://upload-images.jianshu.io/upload_images/6544996-213790567af3d1d9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
可以看到,项目目前就一个Master分支
![](https://upload-images.jianshu.io/upload_images/6544996-db44c64d22dd3d21.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/432)
点击New Branch新建分支,输入分支名V1,点击OK
![](https://upload-images.jianshu.io/upload_images/6544996-236045fd4781d412.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
看到分支V1创建成功
![](https://upload-images.jianshu.io/upload_images/6544996-d0d9bd0e5ffbca06.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
右击项目--Git--Repository--Branches...可以看到本地分支多了个V1分支
![](https://upload-images.jianshu.io/upload_images/6544996-a301cc37b296ba85.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
创建一个V1.java文件,便于区分分支
![](https://upload-images.jianshu.io/upload_images/6544996-09e44ae05f65ba28.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
点击Commit+Push上传到远程仓库
![](https://upload-images.jianshu.io/upload_images/6544996-4cb664e04a2c0e6a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
提示上传成功
![](https://upload-images.jianshu.io/upload_images/6544996-40efd80cc35db34e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/668)
我们去码云远程仓库看一下,可以发现V1上传成功了
![](https://upload-images.jianshu.io/upload_images/6544996-241f4ee47240c222.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
接下来我们把V1合并到Master主分支,右击项目--Git--Repository--Branches...--master--Checkout检出master分支(即切换到master分支)
![](https://upload-images.jianshu.io/upload_images/6544996-97c1d0796fccb0a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
发现V1.java文件不见了,说明分支切换成功
![](https://upload-images.jianshu.io/upload_images/6544996-21156333c642c547.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
然后 右击项目--Git--Repository--Branches...--V1--Merge合并分支
![](https://upload-images.jianshu.io/upload_images/6544996-e47e8880ace4a1e3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
提示合并成功
![](https://upload-images.jianshu.io/upload_images/6544996-8b9c080c3e2542c7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/642)
因为合并是在本地操作的,所以我们还需要push到远程,点击Commit+Push
![](https://upload-images.jianshu.io/upload_images/6544996-40b0855c13b1d6c6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/646)
![](https://upload-images.jianshu.io/upload_images/6544996-9fcda1a47c497470.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
如果提示
![](https://upload-images.jianshu.io/upload_images/6544996-039899bdb15dfb22.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
随便改动一下文件再提交就可以了
![](https://upload-images.jianshu.io/upload_images/6544996-6165bab01390c12a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
提示Push成功,我们去码云看一下Master分支下有V1.java,说明分支合并成功了,两个分支的文件相同,Perfact !!!
![](https://upload-images.jianshu.io/upload_images/6544996-269a8b2cdd67900c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
![](https://upload-images.jianshu.io/upload_images/6544996-7dc228ffbbbcc880.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
可通过以下途径关注本人:
Github https://github.com/Zachary46
CSDN博客 https://blog.csdn.net/Zachary_46
博客园 https://www.cnblogs.com/Zachary46