存储库同步结果为"fatal: Not a git repository: 'working_dir/.repo/projects/external/ipsec-tools.git'"



我正在尝试下载Android源代码,并按照 https://source.android.com/source/downloading.html 中所述的过程进行操作,其中包括安装存储库脚本,然后运行

$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync

获取主分支。我还尝试使用 -f -j1 标志来检查错误并仅使用一个内核,正如网上某处所建议的那样。在这一点上,我认为我非常接近下载整个东西,但在使用 ipsec 工具时,它总是会在最后停止。它始终提供以下输出:

    Fetching project platform/external/ipsec-tools
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     1  100     1    0     0      3      0 --:--:-- --:--:-- --:--:--     3
100 1690k  100 1690k    0     0  2307k      0 --:--:-- --:--:-- --:--:-- 2307k
fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'
Traceback (most recent call last):
  File "/home/sebastian/WORKING_DIR/.repo/repo/main.py", line 500, in <module>
    _Main(sys.argv[1:])
  File "/home/sebastian/WORKING_DIR/.repo/repo/main.py", line 476, in _Main
    result = repo._Run(argv) or 0
  File "/home/sebastian/WORKING_DIR/.repo/repo/main.py", line 155, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 635, in Execute
    fetched = self._Fetch(to_fetch, opt)
  File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 339, in _Fetch
    self._FetchProjectList(**kwargs)
  File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 234, in _FetchProjectList
    success = self._FetchHelper(opt, project, *args, **kwargs)
  File "/home/sebastian/WORKING_DIR/.repo/repo/subcmds/sync.py", line 275, in _FetchHelper
    no_tags=opt.no_tags, archive=self.manifest.IsArchive)
  File "/home/sebastian/WORKING_DIR/.repo/repo/project.py", line 1110, in Sync_NetworkHalf
    no_tags=no_tags)):
  File "/home/sebastian/WORKING_DIR/.repo/repo/project.py", line 1845, in _RemoteFetch
    self.bare_git.pack_refs('--all', '--prune')
  File "/home/sebastian/WORKING_DIR/.repo/repo/project.py", line 2483, in runner
    p.stderr))
error.GitError: platform/external/ipsec-tools pack-refs: fatal: Not a git repository: '/home/sebastian/WORKING_DIR/.repo/projects/external/ipsec-tools.git'

由于它说它不是一个 git 存储库,所以我只是预感并在它指示的目录上运行git init,这不起作用。我还尝试删除整个ipsec-tools.git目录并再次运行存储库同步,以便从头开始,但它总是给出相同的错误。

有什么想法吗?

没有必要

从头开始sync。Android是一个巨大的存储库,可以从头开始下载,为了节省时间和互联网,可以删除特定的git存储库(通常我只看到1个git目录损坏)并重新运行同步。

repo 将项目存储在

.repo/projects

但这些只是指向实际 Git 数据的软链接,这些数据存储在

.repo/project-objects

按照"项目"中的链接删除两个存储库,然后再次运行同步。它对我有用。

平台/框架/支持示例:

rm -fr .repo/projects/frameworks/support.git/ .repo/project-objects/platform/frameworks/support.git/

仅同步此项目:

repo sync -j4 platform/frameworks/support

[我想添加这个作为评论,但它不允许我 - 所以添加为答案]

简短的答案: 删除有问题的存储库/数据:

rm -Rf platform/external/ipsec-tools # from current path
rm -Rf .repo/projects/platform/external/ipsec-tools.git  # soft links 
rm -Rf .repo/project-objects/platform/external/ipsec-tools.git # actual git data

最好只同步有问题的:

repo sync platform/external/ipsec-tools

这对我有用。

我遇到了类似的问题,其中 repo 命令将以相同的错误退出。

我做了一个

临时文件夹,做了一个

repo init

然后做了

repo sync -j4 [PROJECT NAME]

其中项目名称是被损坏的 git。然后,我将 .git 目录从 .repo/projects 文件夹复制到主目录的 .repo/projects,并再次运行 repo 同步来完成它。

最新更新