简体   繁体   English

如何将 git-repo 克隆到本地 LAN

[英]How to create clone a git-repo to local LAN

Sometimes, one may need to execute the following commands to clone a repo to local.有时,可能需要执行以下命令将 repo 克隆到本地。 The repo is around 100GB.回购大约为 100GB。 So is there a way/how to setup to 'clone' the repo in the remote server 'examplecode.org' to a local server so that it didn't need to fetch the codebase remotely?那么有没有办法/如何设置将远程服务器“examplecode.org”中的存储库“克隆”到本地服务器,以便它不需要远程获取代码库?

Originally, the commands to execute are:最初,要执行的命令是:

$repo init -u git://examplecode.org/platform/manifest.git -b release -m ${MyTag} --repo-url=git://examplecode.org/tools/repo.git --repo-branch=my-branch-stable
$repo sync -f -j${CPUS}

Let's 192.168.1.100 be the server in local network, ideally, after the setup, the commands would be like:让我们 192.168.1.100 作为本地网络中的服务器,理想情况下,设置后,命令将如下所示:

$repo init -u git://192.168.1.100/platform/manifest.git -b release -m ${MyTag} --repo-url=git://192.168.1.100/tools/repo.git --repo-branch=my-branch-stable
$repo sync -f -j${CPUS}

repo means git-repo repo意味着git-repo

Many thanks非常感谢

Your repo is 100 GB?你的回购是 100 GB? If that's not a typo, you might consider ways to reduce that size.如果这不是打字错误,您可能会考虑减少该大小的方法。

A good way to start might be by looking for logical ways to split the existing code (and probably a lot of non-code...) across multiple repositories.一个好的开始方法可能是寻找将现有代码(可能还有很多非代码……)拆分到多个存储库中的逻辑方法。 Is the code base sufficiently modular, such that you could move different modules into their own repository?代码库是否足够模块化,以便您可以将不同的模块移动到它们自己的存储库中?

And speaking of non-code, are there a lot of large binary files being kept in the repo?说到非代码,repo 中是否保存了很多大型二进制文件? Maybe those could be taken out of the version control system and moved elsewhere,like a LAN drive or a sharepoint site.也许这些可以从版本控制系统中取出并移到其他地方,例如 LAN 驱动器或共享点站点。 A lot of the benefits of version control are lost with binary files and they just end up taking a ton of space.二进制文件失去了版本控制的许多好处,它们最终只会占用大量空间。

Last, you might want to run git-gc to clean/optimize the repository .最后,您可能想要运行git-gc来清理/优化存储库 This is especially true if you are self-hosting a centralized "master" server (rather than using Github or something similar), since that may not be happening automatically at regular intervals.如果您自托管一个集中式“主”服务器(而不是使用 Github 或类似的东西),则尤其如此,因为这可能不会定期自动发生。

Edit :编辑
I realize this doesn't directly answer the stated question.我意识到这并不能直接回答上述问题。 But it seems OP may have some other areas to explore that would make the sought after solution less urgent.但似乎 OP 可能还有其他一些领域需要探索,这将使寻求的解决方案不那么紧迫。

Edit 2 :编辑2
Based on the comments, it sounds like there is some confusion about what git does versus what repo (the Android wrapper for git ) gives you on top of git.根据评论,对于git作用与repogit的 Android 包装器)在git之上为您提供的内容,听起来有些混淆。 First, and most importantly, you can freely switch between repo and git commands .首先,也是最重要的,您可以在repogit命令之间自由切换 Using one does not bar you from using the other.使用其中一种并不妨碍您使用另一种。 The repo script is just a wrapper that simplifies some operations that are common when developing for Android, but which are cumbersome to do manually with git . repo脚本只是一个包装器,它简化了一些在为 Android 开发时常见的操作,但使用git手动执行这些操作很麻烦。 Outside of those operations, most of the repository manipulation will probably be done using the standard git commands.除了这些操作之外,大部分存储库操作可能会使用标准的git命令来完成。

Regarding the original question, what you are describing is the git clone command:关于原始问题,您所描述的是git clone命令:

NAME姓名
git-clone - Clone a repository into a new directory git-clone - 将存储库克隆到新目录中

SYNOPSIS概要

git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] [--dissociate] [--separate-git-dir <git dir>] [--depth <depth>] [--[no-]single-branch] [--no-tags] [--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules] [--jobs <n>] [--] <repository> [<directory>]

DESCRIPTION描述
Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch -r ), and creates and checks out an initial branch that is forked from the cloned repository's currently active branch.将存储库克隆到新创建的目录中,为克隆存储库中的每个分支创建远程跟踪分支(使用git branch -r可见),并创建并检出从克隆存储库当前活动分支分叉的初始分支。

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch [...]克隆之后,不带参数的普通git fetch将更新所有远程跟踪分支,而不带参数的git pull还会将远程 master 分支合并到当前的 master 分支中 [...]

Since you specifically mentioned wanting to have the code base on the local network, you would first clone the repository and then pull all branches:由于您特别提到希望在本地网络上拥有代码库,您将首先克隆存储库,然后拉取所有分支:

git clone [remote URL]
git pull --all

Once that is done, you can use any repo and regular git commands to manage your local copy of the repository.完成后,您可以使用任何repo和常规git命令来管理存储库的本地副本。

Found 2 ways to do it:找到了2种方法:

  1. Using repo 's --mirror option to create a local mirror, then use --reference to checkout by referencing the mirror使用repo--mirror选项创建本地镜像,然后使用--reference通过引用镜像来结帐

  2. Using grokmirror , pls ref https://git.kernel.org/pub/scm/utils/grokmirror/grokmirror.git/tree/README.rst使用grokmirror ,请参考https://git.kernel.org/pub/scm/utils/grokmirror/grokmirror.git/tree/README.rst

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

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