1. repo sync失败?

error: Your local changes to the following files would be overwritten by checkout:<span style="white-space:pre"></span>default.xmlPlease, commit your changes or stash them before you can switch branches.Abortingerror: .repo/manifests/: manifests checkout d3c00c789b3ab2f87c88c6d7b516d8cc8a41efcfTraceback (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_r5Ddefault.xmlNote: checking out 'android-5.0.0_r5'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:  git checkout -b new_branch_nameHEAD 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_r5Ddefault.xmlSwitched 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.xmlPlease, commit your changes or stash them before you can switch branches.Aborting.repo/manifests/: leaving android-5.0.0_r5; does not track upstreamerror: .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.xmlPlease, commit your changes or stash them before you can switch branches.Aborting.repo/manifests/: leaving android-5.0.0_r5; does not track upstreamerror: .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 5HEAD 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.xmlPlease, commit your changes or stash them before you can switch branches.Aborting.repo/manifests/: leaving android-5.0.0_r5; does not track upstreamerror: .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_r4Note: checking out 'android-5.1.1_r4'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:  git checkout -b new_branch_nameHEAD 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.xmlPlease, commit your changes or stash them before you can switch branches.Aborting.repo/manifests/: discarding 38 commitserror: .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.xmlPlease, commit your changes or stash them before you can switch branches.Aborting.repo/manifests/: discarding 38 commitserror: .repo/manifests/: manifests checkout b5be3a6e170421b0ebb310162c77fb4d171a3742 “ **Error: sync failed, re-sync again** ”

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

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

$ cd .repo/manifests[exocet@exocet:manifests]$ lsdefault.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 commitsFetching project platform/external/timezonepicker-supportFetching project platform/packages/wallpapers/HoloSpiralFetching project platform/hardware/invensenseFetching project platform/packages/apps/DialerFetching projects:   0% (1/471)  Fetching project platform/external/iproute2Fetching project device/google/accessory/demokitFetching project platform/hardware/intel/bootstub

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

A:查看一下git --version,

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



更多相关文章

  1. init.rc 中on propert: 触发无效
  2. Android布局文件.xml中的自定义属性(结合封装的自定义View)
  3. Qt在Android平台上实现html转PDF的功能
  4. Android(安卓)Calendar的学习与运用
  5. Android(安卓)Code Review
  6. ImageLoader修改后
  7. MT6735修改听筒增益
  8. 佛祖保佑 永无BUG 永不修改
  9. Android(安卓)Studio3.0 Annotation processors must be explici

随机推荐

  1. Android–手掌中的王者?
  2. Android(安卓)Studio 初体验
  3. android 开发中中,经常用到的代码
  4. Android之Service学习篇一:Service启动方
  5. Android(安卓)使用 TableLayout 布局拉伸
  6. [原]Ubuntu 14.04编译Android(安卓)Kerne
  7. android 项目中接入flutter模块(部分页面
  8. android 中隐藏EditText的下划线方法
  9. Android(安卓)AOSP源码下载编译
  10. Android(安卓)AndBox 安安卜1.3发布