Android repo Q&A

1. repo sync失败?

error: Your local changes to the following files would be overwritten by checkout:
<span style="white-space:pre">	</span>default.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
error: .repo/manifests/: manifests checkout d3c00c789b3ab2f87c88c6d7b516d8cc8a41efcf 
Traceback (most recent call last):
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/main.py", line 506, in <module>
    _Main(sys.argv[1:])
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/main.py", line 482, in _Main
    result = repo._Run(argv) or 0
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/main.py", line 161, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/subcmds/init.py", line 390, in Execute
    self._SyncManifest(opt)
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/subcmds/init.py", line 239, in _SyncManifest
    m.Sync_LocalHalf(syncbuf)
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/project.py", line 1264, in Sync_LocalHalf
    upstream_gain = self._revlist(not_rev(HEAD), revid)
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/project.py", line 2309, in _revlist
    return self.work_git.rev_list(*a, **kw)
  File "/home/exocet/codePrj/fisher/google/system/.repo/repo/project.py", line 2503, in rev_list
    p.stderr))
error.GitError: manifests rev-list ('^HEAD', u'd3c00c789b3ab2f87c88c6d7b516d8cc8a41efcf', '--'): fatal: bad revision '^HEAD'

A: 查看一下有没有本地分支; -- 很可能你误操作把本地默认分支给整没了!

    $ git --git-dir=.repo/manifests/.git/ branch -a

正常情形(纯净版本):

$ git --git-dir=.repo/manifests/.git/ branch -a
* default
  remotes/m/android-4.4.4_r2 -> origin/android-4.4.4_r2
  remotes/m/android-5.0.0_r5 -> origin/android-5.0.0_r5
  remotes/origin/adt_23.0.3
  remotes/origin/android-1.6_r1
  remotes/origin/android-1.6_r1.1
  remotes/origin/android-1.6_r1.2
  remotes/origin/android-1.6_r1.3
  remotes/origin/android-1.6_r1.4
  remotes/origin/android-1.6_r1.5
  remotes/origin/android-1.6_r2
  remotes/origin/android-2.0.1_r1

出错情形,default没了:

$ git --git-dir=.repo/manifests/.git/ branch -a
  remotes/m/android-4.4.4_r2 -> origin/android-4.4.4_r2
  remotes/m/android-5.0.0_r5 -> origin/android-5.0.0_r5
  remotes/origin/adt_23.0.3
  remotes/origin/android-1.6_r1
  remotes/origin/android-1.6_r1.1
  remotes/origin/android-1.6_r1.2
  remotes/origin/android-1.6_r1.3
  remotes/origin/android-1.6_r1.4
  remotes/origin/android-1.6_r1.5
  remotes/origin/android-1.6_r2
  remotes/origin/android-2.0.1_r1
  remotes/origin/android-2.0_r1
  remotes/origin/android-2.1_r1
  remotes/origin/android-2.1_r2
  remotes/origin/android-2.1_r2.1p
  remotes/origin/android-2.1_r2.

默认本地分支指向default的!由于我想sync到android-5.1.1_r4版本,就出现上面的错误了;

        $ repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.1_r4
   

    提示我default.xml被修改了,status一下:

        $ git --git-dir=.repo/manifests/.git/ status 

    除了default.xml被修改,其余整个目录都被 Untracked了!

    删除.repo太不明智了,.repo就得几十个G!

    

    由于不熟悉repo,又不想删掉重下,做了如下处理:

    能否checkout 出一个新的本地分支?

    $ git --git-dir=.repo/manifests/.git/ checkout android-5.0.0_r5

$ git --git-dir=.repo/manifests/.git/ checkout android-5.0.0_r5
D	default.xml
Note: checking out 'android-5.0.0_r5'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at fa50451... Manifest for Android 5.0.0 release 5
$ git --git-dir=.repo/manifests/.git/ branch -a
* (no branch)
  remotes/m/android-4.4.4_r2 -> origin/android-4.4.4_r2
  remotes/m/android-5.0.0_r5 -> origin/android-5.0.0_r5
  remotes/origin/adt_23.0.3
  remotes/origin/android-1.6_r1
看来切换成功了?

$ git --git-dir=.repo/manifests/.git/ checkout -b android-5.0.0_r5
D	default.xml
Switched to a new branch 'android-5.0.0_r5'
[exocet@exocet:system]$ git --git-dir=.repo/manifests/.git/ branch -a
* android-5.0.0_r5
  remotes/m/android-4.4.4_r2 -> origin/android-4.4.4_r2
  remotes/m/android-5.0.0_r5 -> origin/android-5.0.0_r5
  remotes/origin/adt_23.0.3
好的,repo sync一下:

$ ./repo-sync 
Starting repo sync ...
error: Your local changes to the following files would be overwritten by checkout:
	default.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
.repo/manifests/: leaving android-5.0.0_r5; does not track upstream
error: .repo/manifests/: manifests checkout b5be3a6e170421b0ebb310162c77fb4d171a3742 
“ **Error: sync failed, re-sync again** ”
error: Your local changes to the following files would be overwritten by checkout:
	default.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
.repo/manifests/: leaving android-5.0.0_r5; does not track upstream
error: .repo/manifests/: manifests checkout b5be3a6e170421b0ebb310162c77fb4d171a3742 
“ **Error: sync failed, re-sync again** ”
根据提示stash一下,就是我想切换分支有不想提交当前的修改:

 git --git-dir=.repo/manifests/.git/ stash 
Saved working directory and index state WIP on android-5.0.0_r5: fa50451 Manifest for Android 5.0.0 release 5
HEAD is now at fa50451 Manifest for Android 5.0.0 release 5
[exocet@exocet:system]$ git --git-dir=.repo/manifests/.git/ branch -a
* android-5.0.0_r5
  remotes/m/android-4.4.4_r2 -> origin/android-4.4.4_r2
  remotes/m/android-5.0.0_r5 -> origin/android-5.0.0_r5
  remotes/origin/adt_23.0.3
  remotes/origin/android-1.6_r1
  remotes/origin/android-1.6_r1.1
  remotes/origin/android-1.6_r1.2
  remotes/origin/android-1.6_r1.3
执行成功,sync一下:

$ ./repo-sync 
Starting repo sync ...
error: Your local changes to the following files would be overwritten by checkout:
	default.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
.repo/manifests/: leaving android-5.0.0_r5; does not track upstream
error: .repo/manifests/: manifests checkout b5be3a6e170421b0ebb310162c77fb4d171a3742 
“ **Error: sync failed, re-sync again** ”
还是出错了,好吧,先repo branches本地工作分支做个备份:

$ repo start android-5.0.0_r5-Hz --all
$  repo checkout android-5.0.0_r5-Hz
$ repo branches
*  android-5.0.0_r5-Hz       | in all projects


接着我最终是想sync到 android-5.1.1_r4,再试一次:

$ git --git-dir=.repo/manifests/.git/ checkout android-5.1.1_r4
Note: checking out 'android-5.1.1_r4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at d3c00c7... Manifest for Android 5.1.1 release 4
[exocet@exocet:system]$ git --git-dir=.repo/manifests/.git/ branch 
* (no branch)
  android-5.0.0_r5
ok,已经切换到android-5.1.1_r4,
$ ./repo-sync 
Starting repo sync ...
error: Your local changes to the following files would be overwritten by checkout:
	default.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
.repo/manifests/: discarding 38 commits
error: .repo/manifests/: manifests checkout b5be3a6e170421b0ebb310162c77fb4d171a3742 
“ **Error: sync failed, re-sync again** ”

error: Your local changes to the following files would be overwritten by checkout:
	default.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
.repo/manifests/: discarding 38 commits
error: .repo/manifests/: manifests checkout b5be3a6e170421b0ebb310162c77fb4d171a3742 
“ **Error: sync failed, re-sync again** ”

我们已经在android-5.1.1_r4上了,但是有修改没有提交,提交或者放弃就可以了,

上面stash不行,这里直接reset掉:

$ cd .repo/manifests
[exocet@exocet:manifests]$ ls
default.xml
[exocet@exocet:manifests]$ git reset --hard 
HEAD is now at d3c00c7 Manifest for Android 5.1.1 release 4
熟悉的味道又回来了:

$ repo sync
.repo/manifests/: discarding 38 commits
Fetching project platform/external/timezonepicker-support
Fetching project platform/packages/wallpapers/HoloSpiral
Fetching project platform/hardware/invensense
Fetching project platform/packages/apps/Dialer
Fetching projects:   0% (1/471)  Fetching project platform/external/iproute2
Fetching project device/google/accessory/demokit
Fetching project platform/hardware/intel/bootstub

2. fatal: git fetch-pack: expected shallow list?

A:查看一下git --version,

shallow需要1.9.+以上的版本支持,更新一下git就ok了;



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值