您的位置:首页 > 编程语言

Repo切换分支与同步代码

2017-03-22 16:53 239 查看
自从Android使用repo管理代码后,不同分支间的切换,变得不太直观,不向git那样,可以直接输入分支名称,然后切换,但熟悉了repo的语法后,你会发现其实repo切换分支,也比较简单快捷。

1, 查看可切换的分支

在AOSP目录下

cd .repo/manifests
git branch -a | cut -d / -f 3


2,切换分支(以android-7.0.0_r1为例)

repo init -u https://android.googlesource.com/platform/manifest -b android-7.0.0_r1


3,同步代码

repo sync


如果本地版本库中的源代码有一些改动,执行上述命令后,会出现如下提示(笔者本地为例):

build/: discarding 1 commits
dalvik/: discarding 2 commits
kernel/: discarding 6 commits
packages/apps/Calendar/: discarding 1 commits
packages/apps/Contacts/: discarding 2 commits
packages/apps/Mms/: discarding 1 commits
packages/apps/Music/: discarding 1 commits
packages/apps/Phone/: discarding 1 commits
vendor/embinux/support-tools/: discarding 1 commits


这时需要使用下面的操作命令:

1,repo forall -c git reset --hard
2,repo init -u https://android.googlesource.com/platform/manifest -b android-7.0.0_r1
3,repo sync


这样,本地代码就和服务端仓库中的代码完全一致了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android