Android 源码下载完成后,如何切换单个Git库的版本到历史任意版本?


1.通过git tag命令查看版本号

Administrator@USER-20140803NQ MINGW32 /c/androidandroidandroidandroid/Android7.0/base7.0/base (master)
$ git tag
afw-test-harness-1.5
afw-test-harness-2.1
android-1.6_r1
android-1.6_r1.1
android-1.6_r1.2
android-1.6_r1.3
android-1.6_r1.4
android-1.6_r1.5
android-1.6_r2
android-2.0.1_r1
android-2.0_r1
android-2.1_r1
android-2.1_r2
android-2.1_r2.1p
android-2.1_r2.1p2
android-2.1_r2.1s
android-2.2.1_r1
android-2.2.1_r2
android-2.2.2_r1
android-2.2.3_r1
android-2.2.3_r2
android-2.2.3_r2.1
android-2.2_r1
android-2.2_r1.1
android-2.2_r1.2
android-2.2_r1.3
android-2.3.1_r1
android-2.3.2_r1
android-2.3.3_r1
android-2.3.3_r1.1
android-2.3.4_r0.9
android-2.3.4_r1
android-2.3.5_r1
android-2.3.6_r0.9
android-2.3.6_r1
android-2.3.7_r1
android-2.3_r1
android-3.2.4_r1
android-4.0.1_r1
android-4.0.1_r1.1
android-4.0.1_r1.2
android-4.0.2_r1
android-4.0.3_r1
android-4.0.3_r1.1
android-4.0.4_r1
android-4.0.4_r1.1
android-4.0.4_r1.2
android-4.0.4_r2
android-4.0.4_r2.1
android-4.1.1_r1
android-4.1.1_r1.1
android-4.1.1_r2
android-4.1.1_r3
android-4.1.1_r4
android-4.1.1_r5
android-4.1.1_r6
android-4.1.1_r6.1
android-4.1.2_r1
android-4.1.2_r2
android-4.1.2_r2.1
android-4.2.1_r1
android-4.2.1_r1.1
android-4.2.1_r1.2
android-4.2.2_r1
android-4.2.2_r1.1
android-4.2.2_r1.2
android-4.2_r1
android-4.3.1_r1
android-4.3_r0.9
android-4.3_r0.9.1
android-4.3_r1
android-4.3_r1.1
android-4.3_r2
android-4.3_r2.1
android-4.3_r2.2
android-4.3_r2.3
android-4.3_r3
android-4.3_r3.1
android-4.4.1_r1
android-4.4.1_r1.0.1
android-4.4.2_r1
android-4.4.2_r1.0.1
android-4.4.2_r2
android-4.4.2_r2.0.1
android-4.4.3_r1
android-4.4.3_r1.0.1
android-4.4.3_r1.1
android-4.4.3_r1.1.0.1
android-4.4.4_r1
android-4.4.4_r1.0.1
android-4.4.4_r2
android-4.4.4_r2.0.1
android-4.4_r0.7
android-4.4_r0.8
android-4.4_r0.9
android-4.4_r1
android-4.4_r1.0.1
android-4.4_r1.1
android-4.4_r1.1.0.1
android-4.4_r1.2
android-4.4_r1.2.0.1
android-4.4w_r1
android-5.0.0_r1
android-5.0.0_r2
android-5.0.0_r3
android-5.0.0_r4
android-5.0.0_r5
android-5.0.0_r5.1
android-5.0.0_r6
android-5.0.0_r7
android-5.0.1_r1
android-5.0.2_r1
android-5.0.2_r3
android-5.1.0_r1
android-5.1.0_r3
android-5.1.0_r4
android-5.1.0_r5
android-5.1.1_r1
android-5.1.1_r10
android-5.1.1_r12
android-5.1.1_r13
android-5.1.1_r14
android-5.1.1_r15
android-5.1.1_r16
android-5.1.1_r17
android-5.1.1_r18
android-5.1.1_r19
android-5.1.1_r2
android-5.1.1_r20
android-5.1.1_r22
android-5.1.1_r23
android-5.1.1_r24
android-5.1.1_r25
android-5.1.1_r26
android-5.1.1_r28
android-5.1.1_r29
android-5.1.1_r3
android-5.1.1_r30
android-5.1.1_r33
android-5.1.1_r34
android-5.1.1_r35
android-5.1.1_r36
android-5.1.1_r37
android-5.1.1_r38
android-5.1.1_r4
android-5.1.1_r5
android-5.1.1_r6
android-5.1.1_r7
android-5.1.1_r8
android-5.1.1_r9
android-6.0.0_r1
android-6.0.0_r11
android-6.0.0_r12
android-6.0.0_r13
android-6.0.0_r2
android-6.0.0_r23
android-6.0.0_r24
android-6.0.0_r25
android-6.0.0_r26
android-6.0.0_r3
android-6.0.0_r4
android-6.0.0_r41
android-6.0.0_r5
android-6.0.0_r6
android-6.0.0_r7
android-6.0.1_r1
android-6.0.1_r10
android-6.0.1_r11
android-6.0.1_r12
android-6.0.1_r13
android-6.0.1_r16
android-6.0.1_r17
android-6.0.1_r18
android-6.0.1_r20
android-6.0.1_r21
android-6.0.1_r22
android-6.0.1_r24
android-6.0.1_r25
android-6.0.1_r26
android-6.0.1_r27
android-6.0.1_r28
android-6.0.1_r3
android-6.0.1_r30
android-6.0.1_r31
android-6.0.1_r32
android-6.0.1_r33
android-6.0.1_r4
android-6.0.1_r40
android-6.0.1_r41
android-6.0.1_r42
android-6.0.1_r43
android-6.0.1_r45
android-6.0.1_r46
android-6.0.1_r47
android-6.0.1_r48
android-6.0.1_r49
android-6.0.1_r5
android-6.0.1_r50
android-6.0.1_r51
android-6.0.1_r52
android-6.0.1_r53
android-6.0.1_r54
android-6.0.1_r55
android-6.0.1_r56
android-6.0.1_r57
android-6.0.1_r58
android-6.0.1_r59
android-6.0.1_r60
android-6.0.1_r61
android-6.0.1_r62
android-6.0.1_r63
android-6.0.1_r65
android-6.0.1_r66
android-6.0.1_r67
android-6.0.1_r68
android-6.0.1_r7
android-6.0.1_r8
android-6.0.1_r9
android-7.0.0_r1
android-7.0.0_r3
android-7.0.0_r4
android-7.0.0_r6
android-cts-2.2_r8
android-cts-2.3_r10
android-cts-2.3_r11
android-cts-2.3_r12
android-cts-4.0.3_r1
android-cts-4.0.3_r2
android-cts-4.0_r1
android-cts-4.1_r1
android-cts-4.1_r2
android-cts-4.1_r4
android-cts-4.2_r1
android-cts-4.2_r2
android-cts-4.4_r1
android-cts-4.4_r4
android-cts-5.0_r3
android-cts-5.0_r4
android-cts-5.0_r5
android-cts-5.0_r6
android-cts-5.0_r7
android-cts-5.0_r8
android-cts-5.0_r9
android-cts-5.1_r1
android-cts-5.1_r10
android-cts-5.1_r2
android-cts-5.1_r3
android-cts-5.1_r4
android-cts-5.1_r5
android-cts-5.1_r6
android-cts-5.1_r7
android-cts-5.1_r8
android-cts-5.1_r9
android-cts-6.0_r1
android-cts-6.0_r2
android-cts-6.0_r3
android-cts-6.0_r4
android-cts-6.0_r5
android-cts-6.0_r6
android-cts-6.0_r7
android-cts-6.0_r8
android-cts-6.0_r9
android-cts-7.0_r1
android-cts-verifier-4.0.3_r1
android-cts-verifier-4.0_r1
android-l-preview_r2
android-m-preview
android-m-preview-1
android-m-preview-2
android-n-preview-1
android-n-preview-2
android-n-preview-3
android-n-preview-4
android-n-preview-5
android-sdk-4.0.3-tools_r1
android-sdk-4.0.3_r1
android-sdk-4.4.2_r1
android-sdk-4.4.2_r1.0.1
android-sdk-adt_r16.0.1
android-sdk-adt_r20
android-sdk-support_r11
android-wear-5.0.0_r1
android-wear-5.1.0_r1
android-wear-5.1.1_r1
android-wear-n-preview-1
android-wear-n-preview-2
android-wear-n-preview-3


2.通过上面git tag查看到版本号,然后执行如下命令

git checkout  -b  本地分支  版本号

eg:假如需要切换到android-1.6_r1 这个版本,那么执行如下命令:

git  checkout   -b  android-1.6_r1  android-1.6_r1

注:此处 本地分支取的名称和版本号相同,这样取名有利于区别与其他本地分支,是一个好的取名方式。

如果执行的过程中,报出如下错误:

Administrator@USER-20140803NQ MINGW32 /c/androidandroidandroidandroid/Android7.0/base7.0/base (master)
$ git checkout   -b android-1.6_r1  android-1.6_r1
fatal: Unable to create 'C:/androidandroidandroidandroid/Android7.0/base7.0/base/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.


那么直接将.git目录下的index.lock文件删掉,然后重新执行上面的操作,见下:


Administrator@USER-20140803NQ MINGW32 /c/androidandroidandroidandroid/Android7.0/base7.0/base (master)
$ git checkout   -b android-1.6_r1  android-1.6_r1
Checking out files: 100% (34234/34234), done.
Switched to a new branch 'android-1.6_r1'

源码已经成功切换到android-1.6_r1版本了。


posted @ 2016-09-11 22:03  行走的思想  阅读(18)  评论(0编辑  收藏  举报  来源