如何使用git-svn将具有非法分支名称的svn库转换为git?

问题描述

| 我正在尝试使用git-svn将公司svn repo加载到git中,但是可悲的是我的一位同事创建了一个分支,该分支的名称中包含非法字符(\\)。现在,当我尝试导入整个历史记录时,git退出并出现错误:
fatal: Cannot lock the ref \'refs/remotes/feature-\\\\-bar\'.
update-ref -m r4 refs/remotes/feature-\\\\-bar 471d9622546803b3712a436c2e2ed6b1490c829a: command returned error: 128
我可以不用分支,因为无论如何它都是过去的方式,但是我不想放弃所有历史,直到分支合并为止。我尝试了--ignore-path选项,但无法使其正常工作,主要是因为我怀疑它仅解决了分支/树干路径(??)中的路径。 有人知道如何解决此问题吗?     

解决方法

        我也不得不忽略一些分支,因为它们使用的是非法字符,而我无法用ѭ1f来获取(在我的情况下,字符是
:
/
)。 解决方案1:为每个分支手动添加其他svn存储库 用
git svn init -s [svn-repository-url]
初始化存储库后,我在
.git/config
中注释了分支配置:
[svn-remote \"svn\"]
    url = [svn-base-url]
    fetch = [project-name]/trunk:refs/remotes/trunk
    #branches = [project-name]/branches/*:refs/remotes/*
    tags = [project-name]/tags/*:refs/remotes/tags/*
要稍后添加分支,我将通过为每个分支添加新的svn位置来实现,例如
[svn-remote \"svn-your-branch\"]
    url = [svn-base-url]
    fetch = [project-name]/branches/your-branch:refs/remotes/your-branch
来源:Git SVN忽略路径如何工作(忽略每日构建标签)?或具有一些实际配置,例如http://www.dmo.ca/blog/20070608113513/ 解决方案2:在配置中明确声明所需的分支 您可以在
.git/config
中定义要提取的分支:
[svn-remote \"svn\"]
    url = [svn-base-url]
    fetch = [project-name]/trunk:refs/remotes/trunk
    branches = [project-name]/branches/{your-branch-1|your-branch-2}:refs/remotes/*
    tags = [project-name]/tags/*:refs/remotes/tags/*
如果在从svn中签出所有内容之后以后可以安全地添加分支,我将更喜欢此解决方案。 资料来源:https://stackoverflow.com/a/3844508/709431 为什么忽略路径不起作用? 根据http://go-dvcs.atlassian.com/display/aod/Advanced+git-svn+options的选择,
git svn --ignore-paths
仅忽略提交内容。因此,它仍将为分支名称创建一个引用。如果分支名称包含非法字符,则此操作将失败。 (此外,与您的假设相反,
ignore-paths
匹配URL部分以外的所有内容,例如,使用above12ѭ之类的配置。)     ,        我将在任何当前分支的开头启动git repo-手动将分支的名称设为git-friendly。对于较旧的历史记录,在需要时以这种方式导入。有时,完全不遵循导入完全不同的机制的svn历史记录的痛苦是不值得的。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...