gpt4 book ai didi

git - svn 到 git 的转换 : Correct remote ref must start with 'refs/' error

转载 作者:太空狗 更新时间:2023-10-29 13:30:37 27 4
gpt4 key购买 nike

(我发布这个问题是为了自己回答这个问题,因为我在别处找不到答案。希望它能帮助遇到同样问题的其他人,并在我下次尝试时帮助我它。)

挑战

我想将 SVN 存储库转换为本地托管的 gitlab GIT 存储库并维护历史记录。

设置

Gitlab 8.5, Ubuntu 14.04 LTS, subversion 1.8.8

问题

最初尝试使用 git-svn 或 svn2git 从 svn 转换为 git 导致以下错误。

错误

svn-remote.svn: remote ref '//example.com:81/svn/myrepository/trunk:refs/remotes/trunk' 必须以 'refs/' 开头

我尝试过的

我已遵循以下外部引用中的两个指南。

使用的外部引用

最佳答案

  1. 生成 authors.txt 文件。这将包含您的 SVN 用户和 Gitlab 用户之间的映射:

    • 来自现有的 svn 存储库:svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
    • 否则,请按照以下格式手动创建它:

      oldSVNusername = newGitlabUsername <gitlabRegisteredEmailAddress@example.com>

  2. 创建一个临时目录init SVN repo

    • mkdir temp
    • cd temp
    • git svn init --no-metadata http://username:password@example.com:81/svn/myrepository
  3. 配置git

    • git config svn.authorsfile ~/authors.txt
    • git config --global user.name myusername
    • git config --global user.email myusername@example.com
  4. 抓取文件并将它们克隆到一个新的 git 存储库中

    • git svn fetch
    • git clone . ../myrepository
    • cd ../myrepository
  5. 在 gitlab 中设置新的存储库,确保您的用户可以访问它。

  6. 添加远程gitlab仓库

    • git remote add gitlab gitlab.example.com:gitlab-group/myrepository.git
  7. 仔细检查您在 myrepository/.git/config 中的配置(尤其是 URL 行)

    [core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    [remote "origin"]
    url = /root/temp/.
    fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
    remote = gitlab
    merge = refs/heads/master
    [remote "gitlab"]
    url = http://gitlab.example.com/gitlab-group/myrepository.git
    fetch = +refs/heads/*:refs/remotes/gitlab/*
    [user]
    name = myusername

  8. 全部推到上游

    • git push --set-upstream gitlab master

现在您应该将所有文件和历史记录转换为 git 并显示在 gitlab 中。

关于git - svn 到 git 的转换 : Correct remote ref must start with 'refs/' error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35900710/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com