简体   繁体   English

Google存储库工具(主分支)无法从Windows上的本地镜像同步

[英]Google repo tool (master branch) fails to sync from local mirror on Windows

Recently master branch for Google repo tool has been updated to support Windows OS. 最近,针对Google回购工具的master分支已更新为支持Windows OS。 It is clear from commit logs : https://gerrit.googlesource.com/git-repo/+log 从提交日志中可以很明显地看出: https : //gerrit.googlesource.com/git-repo/+log

I am able to run basic commands like repo init and repo sync using repo tool on Windows (which makes use of MinGW Git on Windows). 我可以使用Windows上的repo工具(在Windows上使用MinGW Git)运行诸如repo init和repo sync之类的基本命令。 In my work I need to create a local mirror of a repository and then use it. 在我的工作中,我需要创建一个存储库的本地镜像,然后使用它。 repo tool works fine to create mirror repository. repo工具可以很好地创建镜像存储库。

Here are commands used to create mirror repository on local drive on Windows OS. 这是用于在Windows OS的本地驱动器上创建镜像存储库的命令。

$ repo.cmd init -u <URL> -b <branch_name> -m <manifest_file_name> --mirror --no-repo-verify

$ repo.cmd sync --no-tags
  • --no-repo-verify is used to forcefully use master branch of repo tool. --no-repo-verify用于强制使用repo工具的master分支。
  • The above commands create the mirror in local drive C:\\git-repo\\test\\mirror-testing\\mirror 上面的命令在本地驱动器C:\\ git-repo \\ test \\ mirror-testing \\ mirror中创建镜像

But when I refer the above mirror to sync in other drive then it shows error. 但是,当我参考上面的镜像在其他驱动器中同步时,它显示错误。

Command:
$ repo.cmd init -u <URL> -b <Branch_name> -m <manifest_file_name> --reference="C:\git-repo\test\mirror-testing\mirror" --no-repo-verify

Error:
error: object directory C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects? does not exist; check .git/objects/info/alternates.

The above command creates alternates file in C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects/info/ directory and that file contains below path: 上面的命令在C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects/info/目录中创建备用文件,该文件包含以下路径:

C:\git-repo\test\mirror-testing\mirror\project/manifest.git\objects

I have tried other formats to provide reference value: 我尝试了其他格式来提供参考值:

Git format: "/C/git-repo/test/mirror-testing/mirror"
Cygwin format: "/cygdrive/c/git-repo/test/mirror-testing/mirror"

Using above formats in reference does not create alternates file in objects directory. 在引用中使用上述格式不会在对象目录中创建替代文件。

repo init time in all above cases simply suggests that mirror is not referred and init is done from network. 在上述所有情况下,回购初始化时间仅表明未引用镜像,而是通过网络完成初始化。

When I repeat the same test with Cygwin Git + Google repo tool (stable branch) then I do not see any error and repo init time and sync time is very less compared to the mirror init and sync time, which simply suggests that mirror is referred. 当我使用Cygwin Git + Google repo工具(稳定分支)重复相同的测试时,我看不到任何错误,并且repo的初始化时间和同步时间与镜像的init和同步时间相比要少得多,这表明镜像已被引用。

  • repo.cmd is a batch file wrapper to invoke repo tool with python. repo.cmd是批处理文件包装程序,可使用python调用repo工具。 repo.cmd file contains single line repo.cmd文件包含单行

    @call python %~dp0\\repo %* @call python%〜dp0 \\ repo%*

  • I am using Cygwin terminal in Windows 7 to run these commands. 我在Windows 7中使用Cygwin终端运行这些命令。

  • To be clear repo init and repo sync shows error while referring to mirror but it completes successfully by syncing from outside network. 为了清楚起见,repo init和repo sync在引用镜像时显示错误,但通过从外部网络进行同步可以成功完成。 The issue is that mirror is not referred. 问题是未引用镜像。

Has anyone used Google repo on Windows for creating mirror and syncing in other drive using as reference? 是否有人使用Windows上的Google存储库创建镜像并在其他驱动器中进行同步作为参考?

I have tested Google repo tool master branch with MinGW Git on Windows 7 and Windows 10. repo init and repo sync work on both OS. 我已经在Windows 7和Windows 10上使用MinGW Git测试了Google repo工具主分支,这两个操作系统上的repo init和repo sync工作正常。

Even creating the local mirror using --mirror is working, but referring that local mirror to sync in other drive does not work and displays error: "object directory not found". 即使使用--mirror创建本地镜像也可以,但是引用该本地镜像以在其他驱动器中进行同步无法正常工作并显示错误:“找不到对象目录”。

To be clear using --reference with local mirror shows error, but it eventually uses the network and ignores the local mirror. 使用带有本地镜像的--reference进行清除时会显示错误,但最终使用网络并且忽略了本地镜像。 Ultimately the command completes successfully, but it does not make the use of local mirror. 最终,该命令成功完成,但是没有使用本地镜像。 I do not see any workaround for this on Windows for now. 我目前在Windows上看不到任何解决方法。

Meanwhile Windows 10 supports Linux bash natively without using any VM. 同时,Windows 10本机支持Linux bash,而无需使用任何VM。 WSL, the Windows Subsystem for Linux, is a free, optional feature of Windows 10 that allows Linux programs to run on Windows. WSL是Windows的Linux子系统,是Windows 10的一项免费的可选功能,它允许Linux程序在Windows上运行。 It provides you with a Windows version of the bash shell and a compatibility layer that permits many Linux programs to run natively on your Windows machine. 它为您提供bash shell的Windows版本和兼容性层,该兼容性层允许许多Linux程序在Windows计算机上本机运行。 Using this option you can replace Cygwin Git with Linux Git. 使用此选项,您可以将Cygwin Git替换为Linux Git。

I have tested repo tool on Linux Bash (with Ubuntu distribution installed) for repo init, sync, mirror and reference commands and it works. 我已经在Linux Bash(安装了Ubuntu发行版)上测试了回购工具,以进行回购初始化,同步,镜像和参考命令,并且它可以正常工作。 In fact we use Linux bash so simply Goole repo stable branch works, you do not need to use the master branch to make it work. 实际上,我们使用Linux bash只是使Goole repo稳定分支能够正常工作,而无需使用master分支即可使其工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM