问题描述
我正在从事一个项目,我试图将多个模块合并为一个解决方案。每个模块都在自己的文件夹中,并且是 git 存储库。这些都存储在 C:\sourcecode\Modules
中,最终它们将在 GitHub 上。在深入了解使用由存储在 git 存储库中的模块组成的解决方案的不同方法后,我决定尝试 Google 为 AOSP 构建的 Repo
。
我根据此处的 Repo 要求安装了所有工具 https://source.android.com/setup/develop 并在该文件夹中创建了一个文件夹 C:\sourcecode\Repotest
我创建了一个名为 default.xml 的文件。该文件夹的内容非常简单:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="origin"
fetch="/c/sourcecode/Modules" />
<default revision="master"/>
<project path="AnalystQualification" name="AnalystQualification" />
</manifest>
我以管理员身份启动 git-bash 并运行:
$ cd /c/sourcecode/Repotest/
$ repo init -u default.xml
我得到输出:
$ repo init -u default.xml
Downloading manifest from default.xml
Traceback (most recent call last):
File "C:\sourcecode\Repotest\.repo\repo\main.py",line 630,in <module>
_Main(sys.argv[1:])
File "C:\sourcecode\Repotest\.repo\repo\main.py",line 604,in _Main
result = run()
File "C:\sourcecode\Repotest\.repo\repo\main.py",line 597,in <lambda>
run = lambda: repo._Run(name,gopts,argv) or 0
File "C:\sourcecode\Repotest\.repo\repo\main.py",line 266,in _Run
result = cmd.Execute(copts,cargs)
File "C:\sourcecode\Repotest\.repo\repo\subcmds\init.py",line 531,in Execute
self._SyncManifest(opt)
File "C:\sourcecode\Repotest\.repo\repo\subcmds\init.py",line 232,in _SyncManifest
default_branch = m.ResolveRemoteHead()
File "C:\sourcecode\Repotest\.repo\repo\project.py",line 1926,in ResolveRemoteHead
output = self.bare_git.ls_remote('-q','--symref','--exit-code',name,'HEAD')
File "C:\sourcecode\Repotest\.repo\repo\project.py",line 3040,in runner
raise GitError('%s %s: %s' %
error.GitError: manifests ls-remote: fatal: invalid gitfile format: default.xml
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Downloading Repo source from https://gerrit.googlesource.com/git-repo
我认为这个错误告诉我 default.xml 中的设置无法看到 modules/analystqualification
目录中的 .git 文件夹,但如果我 ls -l
$ ls -l /C/sourcecode/Modules/AnalystQualification
total 4
drwxr-xr-x 1 adam.wheeler 1049089 0 Jan 12 10:01 Setup_AQ/
在这里感谢任何帮助。谢谢!
亚当
解决方法
repo init -u url_to_manifest_repo -m foo.xml -b manifest_repo_branch
url_to_manifest_repo
应该是一个跟踪 foo.xml
的 git 存储库。它可以位于本地磁盘或远程托管服务器中。在您的情况下,它是 /c/sourcecode/Repotest
。确保 /c/sourcecode/Repotest
是一个 git 存储库并且 default.xml
已被跟踪。
foo.xml
是清单文件相对于 url_to_manifest_repo
根的路径。 -m foo.xml
可以省略。如果是,则默认使用 -m default.xml
。
manifest_repo_branch
是保存特定版本的 foo.xml
的分支。如果省略 -b manifest_repo_branch
,则默认为 -b master
。
所以在你的情况下,命令是:
repo init -u /c/sourcecode/Repotest -m default.xml -b master
或者简单地说:
repo init -u /c/sourcecode/Repotest
对于本地存储库,它也可以是 -u file:///c/sourcecode/Repotest
。