使用svn元数据克隆git-svn存储库

时间:2011-03-17 13:42:25

标签: svn git git-svn

我用git-svn clone svn://url/trunk --stdlayout克隆了我的主存储库。现在我想用svn元数据克隆存储库。这样我就能git-svn rebase到主服务器。

注意,我不想在两个git-svn克隆之间推送提交,我只想将所有git-svn元数据添加到新克隆的存储库中,以便新克隆能够也与主要的subversion服务器通信。

2 个答案:

答案 0 :(得分:30)

它在docs。你应该做的是:

git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
git fetch

获取svn元分支。然后,您将能够git-svn rebase而无需从头开始获取所有内容。


引用文档:

  

最初的git svn克隆可以很好   耗费时间(特别是对于大型的   Subversion存储库)。如果多个   人(或一个人有多个人)   机器)想用git svn来   与同一个Subversion交互   存储库,你可以做初始的git   svn clone到服务器上的存储库   让每个人克隆那个   存储库与git clone:

# Do the initial import on a server
        ssh server "cd /pub && git svn clone http://svn.example.com/project
# Clone locally - make sure the refs/remotes/ space matches the server
        mkdir project
        cd project
        git init
        git remote add origin server:/pub/project
        git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
        git fetch
# Prevent fetch/pull from remote git server in the future,
# we only want to use git svn for future updates
        git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched
        git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
        git svn init http://svn.example.com/project
# Pull the latest changes from Subversion
        git svn rebase

答案 1 :(得分:2)

远程机器之间的超快速简单复制克隆

来自docs

  

'git clone'不会在refs / remotes / hierarchy或任何'git svn'元数据或config下克隆分支。因此,使用'git svn'创建和管理的存储库应该使用'rsync'进行克隆,如果要进行克隆的话。

同一台计算机上的复制克隆可以使用cp -rp <src> <dst>完成,也可以使用scp -rCp <src> <dst>从远程计算机完成。

然而,远程情况可能非常慢(甚至在以太网上10分钟),因为它必须复制大量的小文件。

使用cpio可以避免这种开销,这意味着(取决于带宽)它只需要几秒钟(对于50Mbit / s连接上的100Mb git repo)。

ssh -C <user>@<host> "cd <path to parent dir of repo>; \
find <repo directory name> -depth -print | cpio -oa" | cpio -imd

例如

ssh -C alex@myhost "cd ~alex/repos/; \
find WonderProject -depth -print | cpio -oa" | cpio -imd

在本地计算机的当前工作目录中生成一个新的git repo'WonderProject'。


(请注意,我所提到的文档几乎否认@Elazar所指的部分的存在,所以我不会诋毁@Elazar的优秀解决方案,但寻找更简洁难忘的解决方案)

相关问题