将SVN迁移到git不会将标签迁移到Azure DevOps

时间:2019-02-27 15:27:06

标签: git azure svn azure-devops migration

我将存储库从自己的Subversion服务器迁移到Azure DevOps git存储库。为此,我使用下一个命令:

# Cloning
git svn clone --stdlayout --authors-file=autors.txt "http://www.subversion.com/svn/<repoName>" <repoName>
Set-Location <repoName>

# Creation of the repository using the REST APIs of DevOps by a .NET application

# Pushing
git remote add origin "https://organisation@dev.azure.com/organisation/repoName/_git/repoName";
git push -u origin --all;
git push origin --tags;

# Pushing each branch
[string[]]$svnBranches = svn ls "http://www.subversion.com/svn/<repoName>/branches/";

$svnBranches | ForEach-Object {
    [string]$name = $_.TrimEnd("/");
    Write-Host $name;
    git checkout $name;
    git push;
}

问题在于标签未推送到DevOps。我到处搜索,发现git push origin --tags,但这行不通。

我为分支创建了解决方法,以将其保留在DevOps存储库中,否则也将其删除。

这种解决方法我无法重复使用代码,因为git tag -l没有给出结果,并且svn ls "http://www.subversion.com/svn/<repoName>/tags/"出现了这个错误:

  

svn: E170013:无法连接到URL为http://www.subversion.com/svn/<repoName>/tags/的存储库

     

svn: E175003:位于http://www.subversion.com/svn/<repoName>/tags/的服务器不支持HTTP / DAV协议

还能将标签迁移到Azure DevOps git存储库吗?

2 个答案:

答案 0 :(得分:0)

源自this post,这是我们正在使用的内容(不是使用DevOps,而是在GitLab和GitHub上工作的):

git svn clone https://.......
# Create repo on hosting service
cd <the-repo.git>
git for-each-ref --format='%(refname)' refs/remotes/origin/tags | cut -d/ -f5 | while read ref; do 
  git tag -a "$ref" -m "$(git log --pretty=oneline refs/remotes/origin/tags/$ref | head -n1 | cut -d' ' -f2-)" "refs/remotes/origin/tags/$ref"
  git update-ref -d "refs/remotes/origin/tags/$ref"
done
git remote add origin .............
git push origin 'refs/remotes/origin/*:refs/heads/*'
git push origin --tags

答案 1 :(得分:0)

我相信您应该使用以下命令将数据推送到DevOps:

git push -u --all --follow-tags origin

使用此命令,所有内容都应发送到原始位置,包括标签。

顺便说一句,还有另一个工具可以将数据从SVN转换为Git,其名称为SubGit:

https://subgit.com

它可能允许导入更复杂的存储库,这可能对您的工作有所帮助。

相关问题