获取Android源代码使用repo sync命令,但经常会出错,导致获取不了最新的代码。
出现以下的类似错误:
From https://android.googlesource.com/platform/manifest
* [new branch] android-cts-2.3_r12 -> origin/android-cts-2.3_r12
* [new tag] android-cts-2.3_r12 -> android-cts-2.3_r12
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "/usr/lib/python2.6/threading.py", line 484, in run
self.__target(*self.__args, **self.__kwargs)
File "/cygdrive/f/OpenSource/Android/.repo/repo/subcmds/sync.py", line 186, in _FetchHelper
current_branch_only=opt.current_branch_only)
File "/cygdrive/f/OpenSource/Android/.repo/repo/project.py", line 929, in Sync_NetworkHalf
current_branch_only=current_branch_only):
File "/cygdrive/f/OpenSource/Android/.repo/repo/project.py", line 1428, in _RemoteFetch
if GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy).Wait() == 0:
File "/cygdrive/f/OpenSource/Android/.repo/repo/git_command.py", line 215, in __init__
raise GitError('%s: %s' % (command[1], e))
GitError: fetch: [Errno 13] Permission denied
上网查了一番,发现到相应的工程运行一下git checkout -f就可以解决了。但是每次这样搞法也是费时费力啊。
查了一下repo的命令参数,发现repo forall可以对所有项目执行一个命令。于是就有了以下的解决办法:
repo forall -c git checkout -f
repo sync -f