将仓库从 git 导入到 gerrit
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14789666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Import repository from git to gerrit
提问by DEgITx
I have two questions about Gerrit:
我有两个关于 Gerrit 的问题:
How do I convert or import an already existing Git repository into Gerrit's format?There were a lot of commits without Gerrit control, I want to simply push those commits into a Gerrit project.
I see two ways to do it:
Copy existing bare Git directory to Gerrit and then add it to database. Is that a safe method?
Push all commits from my local repository to gerrit repository.
How to revert repository from Gerrit to original Git format?Is it required to remove Gerrit's special
*/for/*
branches to do that?
如何将已经存在的 Git 存储库转换或导入 Gerrit 的格式?有很多没有 Gerrit 控制的提交,我想简单地将这些提交推送到 Gerrit 项目中。
我看到了两种方法:
将现有的裸 Git 目录复制到 Gerrit,然后将其添加到数据库中。这是一种安全的方法吗?
将所有提交从我的本地存储库推送到 gerrit 存储库。
如何将存储库从 Gerrit 恢复为原始 Git 格式?是否需要删除 Gerrit 的特殊
*/for/*
分支才能做到这一点?
回答by helmbert
First of all: There is no special "Gerrit format". Gerrit works with regular git repositories.
首先:没有特殊的“Gerrit 格式”。Gerrit 使用常规 git 存储库。
Create a new project in Gerrit (without an initial commit). Add the created repository as a remote to your existing repository and simply push. You can configure Gerrit to allow direct pushing into the repository (bypassing review), allowing you to import the entire repository.
Alternatively, if you have direct access to Gerrit's repository location (e.g. via SSH or on the local filesystem), you can just push directly into the repository (whereever Gerrit created it), bypassing Gerrit entirely. You'll need to flush the Gerrit caches afterwards, however, for Gerrit to notice that the repository HEADs have updated.
As said, there is no "Gerrit format". Just clone your repository from gerrit, and all is well. You don't need to worry about any special branches.
在 Gerrit 中创建一个新项目(没有初始提交)。将创建的存储库作为远程添加到您现有的存储库,然后简单地推送。您可以配置 Gerrit 以允许直接推送到存储库(绕过),从而允许您导入整个存储库。
或者,如果您可以直接访问 Gerrit 的存储库位置(例如,通过 SSH 或在本地文件系统上),您可以直接推送到存储库(无论 Gerrit 创建它的地方),完全绕过 Gerrit。但是,您需要在之后刷新 Gerrit 缓存,以便 Gerrit 注意到存储库 HEAD 已更新。
如前所述,没有“Gerrit 格式”。只需从 gerrit 克隆您的存储库,一切都很好。您无需担心任何特殊分支。
回答by beka
I imported many GIT projects to gerrit, the easiest way I found was to copy the xy.git Directory of the git repository to the directory where gerrit deposits the git repos. After restart of gerrit process the new project is in the list of new projects and you can edit description and access rights.
我在gerrit中导入了很多GIT项目,我找到的最简单的方法是将git仓库的xy.git目录复制到gerrit存放git仓库的目录下。重新启动gerrit 进程后,新项目在新项目列表中,您可以编辑描述和访问权限。
回答by Kalle Pokki
Just create the new project in Gerrit, and then push the git repository there. If you want to bypass review, push directly to master instead of refs/for/master. You'll need to add the permission to do this to yourself.
I think the error message may be caused by you not having imported your ssh key to Gerrit yet.
Just clone the repository from Gerrit. It won't include any extra branches.
只需在 Gerrit 中创建新项目,然后将 git 存储库推送到那里。如果你想绕过,直接推送到 master 而不是 refs/for/master。您需要为自己添加权限才能执行此操作。
我认为该错误消息可能是由于您尚未将 ssh 密钥导入 Gerrit 造成的。
只需从 Gerrit 克隆存储库。它不会包括任何额外的分支。
回答by Trevor Getty
Additional information...
附加信息...
So you can copy the git repository straight across into the gerrit data location and it will show up after a restart ( or flush of cache ( reindex )).
因此,您可以将 git 存储库直接复制到 gerrit 数据位置,它会在重新启动(或刷新缓存( reindex ))后显示。
BUT you will be missing the important configuration from your repository, which may prevent ability to push, create branches, review etc.
但是您将丢失存储库中的重要配置,这可能会阻止推送、创建分支、等的能力。
If you view the repo you will see it is missing the 'refs/meta/config' branch. So in an normal system without changes this will inherit from All-Projects, but this could be any Project on your configuration.
如果您查看 repo,您会发现它缺少“refs/meta/config”分支。因此,在没有更改的普通系统中,这将从 All-Projects 继承,但这可以是您配置中的任何项目。
Steps to fix configuration:
修复配置的步骤:
- List item
- Copy git repo
- Refresh cache / restart gerrit / reindex
- Open repo from project list view
- Click on branches
- Type in the new branch name of "refs/meta/config" at revision "HEAD"
- Click "edit config" from the project general view.
- This creates a file (project.config) in this branch for configuration. Add some default configuration, either taken from a working repo, or as follows:
- 项目清单
- 复制 git 仓库
- 刷新缓存/重启gerrit/reindex
- 从项目列表视图打开 repo
- 点击分行
- 在修订版“HEAD”处输入“refs/meta/config”的新分支名称
- 从项目总视图中单击“编辑配置”。
- 这将在此分支中创建一个文件 (project.config) 以进行配置。添加一些默认配置,或者从工作仓库中获取,或者如下:
e.g.
例如
[access]
inheritFrom = All-Projects
- Click Save, then CLOSE.
- Click Review ( to give it +2)
- Click Publish Edit to save this change into gerrit.
- 单击保存,然后关闭。
- 点击评论(给它+2)
- 单击 Publish Edit 将此更改保存到 gerrit 中。
You can now use the repository with sensible inherited configuration the same as your other projects.
您现在可以像其他项目一样使用具有合理继承配置的存储库。