Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git svn:what';这相当于'svn switch--relocate`?_Git_Version Control_Git Svn - Fatal编程技术网

git svn:what';这相当于'svn switch--relocate`?

git svn:what';这相当于'svn switch--relocate`?,git,version-control,git-svn,Git,Version Control,Git Svn,我正在通过git svn镜像的svn存储库已更改URL 在vanilla svn中,您只需执行svn切换——重新定位旧的\u url\u库新的\u url\u库 如何使用git svn实现这一点 简单地更改配置文件中的svn url失败。Git svn严重依赖svn url。从svn导入的每个提交都有一个包含svn URL的git svn id 有效的重新定位策略是在新存储库上调用git svn clone,并将更改合并到新的close上。有关更详细的过程,请参阅本文: 这很好地处理了我的情况:

我正在通过git svn镜像的svn存储库已更改URL

在vanilla svn中,您只需执行
svn切换——重新定位旧的\u url\u库新的\u url\u库

如何使用git svn实现这一点


简单地更改配置文件中的svn url失败。

Git svn严重依赖svn url。从svn导入的每个提交都有一个包含svn URL的
git svn id

有效的重新定位策略是在新存储库上调用
git svn clone
,并将更改合并到新的close上。有关更详细的过程,请参阅本文:


这很好地处理了我的情况:

我使用
文件://
协议进行克隆,并希望切换到
http://
协议

编辑
.git/config
[svn remote“svn”]
部分中的
url
设置很有诱惑力,但这本身不起作用。通常,您需要遵循以下步骤:

  • 将svn remote
    url
    设置切换为新名称
  • 运行
    git svn fetch
    。这需要从svn获取至少一个新版本
  • 将svn remote
    url
    设置更改回原始url
  • 运行
    git svn rebase-l
    以执行本地rebase(使用上次获取操作中的更改)
  • 将svn remote
    url
    设置更改回新的url
  • 现在,
    git-svn-rebase
    应该可以再次工作了

  • 喜欢冒险的人可能会想试试。

    你可以看看下面的方法是否可行:

  • 如果配置文件(
    .git/config
    )中不存在
    svn remote.svn.rewriteRoot
    ):

    可从
    .git/svn/.metadata
    获取
    currentRepositoryUUID

  • git config svn-remote.svn.url


  • 不幸的是,这些答案中的大多数链接都不起作用,因此我将从中复制一些信息,以供将来参考

    这个解决方案对我有效:

    • 编辑
      .git/config
      中的
      svn remote
      url
      (或
      fetch
      路径)以指向新的 域/url/路径

    • 运行git
      git svn fetch
      。这需要从svn获取至少一个新版本

    • 如果您现在尝试
      git svn rebase
      ,将收到如下错误消息:

      Unable to determine upstream SVN information from working tree history
      
      我认为这是因为
      git svn
      被一个事实弄糊涂了,即在获取之前的最新提交将有一个
      git svn id
      指向旧路径,该路径与
      .git/config
      中找到的路径不匹配

    • 作为一种解决方法,将
      svn remote
      url
      (或
      fetch
      path)更改回原始域/url/path

    • 现在再次运行
      git svn rebase-l
      ,以使用上次获取操作中的更改来执行本地rebase。这一次它会起作用,显然是因为新头部的
      git svn id
      .git/config
      中的id不匹配这一事实不会让
      git svn
      感到困惑

    • 最后,将
      svn remote
      url
      (或
      fetch
      path)更改回新域/url/path

    • 此时,
      git svn rebase
      应该可以再次工作了

    找到了原始信息。

    git筛选器分支
    ,取自,为我工作。提供旧的和新的repo URL作为参数,就像svn开关--relocate一样

    脚本调用
    git filter branch
    来替换提交消息中
    git svn id
    中的Subversion URL,更新
    .git/config
    ,还通过使用
    git svn rebase
    重新创建元数据来更新
    git svn
    元数据。虽然
    git svn clone
    可能是更健壮的解决方案,但是
    filter branch
    方法对于大型存储库的运行速度要快得多(数小时vs.数天)

    #/垃圾箱/垃圾箱
    #必须使用两个命令行参数调用。
    #示例:git-svn-relocate.shhttp://old.server https://new.server
    如果[$#-ne 2]
    然后
    echo“请使用两个命令行参数(旧的和新的SVN URL)调用此脚本。”
    退出$E_NO_参数
    fi
    #准备用于正则表达式搜索和替换的URL。
    oldUrl=`echo$1 | awk'{gsub(“[\\\.]”,“\\\&“;print}”`
    newUrl=`echo$2 | awk'{gsub(“[\\\&]”,“\\\\&”);print}`
    filter=“sed”s | ^git svn id:$oldUrl | git svn id:$newUrl | g”
    git筛选器分支--msg筛选器“$filter”---all
    sed-i.backup-e“s |$oldUrl |$newUrl | g”.git/config
    rm-rf.git/svn
    git-svn-rebase
    
    git\u fast\u过滤器
    但比(即,分钟而不是小时)更快,但精神上相似的是使用。然而,这需要更多的编码,并且不存在整洁的现成解决方案。与git filter branch不同,这将从旧回购创建新回购。假定
    master
    指向最后一个SVN提交

  • 从Gitorious回购中克隆git\u fast\u过滤器
  • 在克隆
    git\u fast\u filter
    的同一目录中创建Python脚本,使用
    chmod+x
    设置可执行位。调整旧的和新的存储库路径。(脚本的内容也粘贴在下面。)
  • 使用git init初始化新的目标存储库,将工作目录更改为此新的repo
  • 执行以下管道:

    (cd path/to/old/repo && git-fast-export --branches --tags --progress=100) | \
        path/to/git_fast_filter/commit_filter.py | git-fast-import
    
  • .git/config
    以及
    .git/info
    中的其他相关文件从旧回购复制到新回购

  • 删除
    .git/svn
  • 使git svn了解新的修订号映射

  • 执行
    git分支refs/remotes/git svn master

    • 您的git svn远程调用可能与
      refs/remotes/git svn不同<
      
      Unable to determine upstream SVN information from working tree history
      
      (cd path/to/old/repo && git-fast-export --branches --tags --progress=100) | \
          path/to/git_fast_filter/commit_filter.py | git-fast-import