将 svn repo 添加到现有的 git repo?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/746151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:19:44  来源:igfitidea点击:

Add svn repo to existing git repo?

svngitgit-svn

提问by rip747

I know you can track a svn repo with git by using git svn init, however that is for if you want to create a brand new repo.

我知道你可以使用 git svn init 来跟踪 svn repo,但是如果你想创建一个全新的 repo。

My situation is that I currently already have an existing git repo and want to track the trunk of a svn repo by making it a remote branch in my current git repo.

我的情况是,我目前已经有一个现有的 git repo,并希望通过将其设置为我当前 git repo 中的远程分支来跟踪 svn repo 的主干。

Any suggestions?

有什么建议?

采纳答案by rip747

After searching last night, I have finally found the answer:

经过昨晚的搜索,我终于找到了答案:

http://i-nz.net/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn-repository/

http://i-nz.net/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn-repository/

It seems that you have to actually go in and manually edit the .git/config file in order to add an svn branch to an existing git repo. So according to these instructions I would have to add an entry for each branch.

似乎您必须实际进入并手动编辑 .git/config 文件才能将 svn 分支添加到现有的 git 存储库。因此,根据这些说明,我必须为每个分支添加一个条目。

回答by Elmer

The answers for this question (https://stackoverflow.com/a/840411and https://stackoverflow.com/a/7592152) no longer work as of Git v1.8.3.2 (https://stackoverflow.com/a/19833311). You can do this instead:

这个问题的答案(https://stackoverflow.com/a/840411https://stackoverflow.com/a/7592152)从 Git v1.8.3.2(https://stackoverflow.com/ a/19833311)。你可以这样做:

1) Define the new branch in .git/config :

1) 在 .git/config 中定义新分支:

[svn-remote "release-branch"]
   url = svn+ssh://[email protected]/source/branches/mono-2-2/mcs
   fetch = :refs/remotes/git-svn-release-branch

2) Import the SVN branch. SVN_BRANCHED_REVISION is the the revision when the branch happened in SVN.

2)导入SVN分支。SVN_BRANCHED_REVISION 是分支在 SVN 中发生时的修订。

$ git svn fetch release-branch -r SVN_BRANCHED_REVISION

3) Create branch and hook up a local Git branch to the remote branch:

3) 创建分支并将本地 Git 分支挂接到远程分支:

$ git checkout -b release refs/remotes/git-svn-release-branch

5) Update

5) 更新

$ git svn rebase

回答by Ian Mariano

You can find the SVN_BRANCHED_REVISION by doing:

您可以通过执行以下操作找到 SVN_BRANCHED_REVISION:

$ svn log --stop-on-copy PATH_TO_BRANCH

回答by jeffcook2150

This is actually what git svn init does -- the other git svn commands simply merge things together, etc. You can git svn init and/or copy the layout of an SVN repo cloned with git svn clone, and you should just be able to pull into a local branch, or fetch, and so on. Have some time with the man page for git svn and you shouldn't have too much trouble piecing something together; if you do, #git on freenode is a good resource. So, this should be possible without too much trouble, but I don't know exactly how to do it all.

这实际上是 git svn init 所做的 - 其他 git svn 命令只是将事物合并在一起,等等。您可以 git svn init 和/或复制使用 git svn clone 克隆的 SVN 存储库的布局,您应该能够拉入本地分支,或获取,等等。花一些时间阅读 git svn 的手册页,你应该不会在拼凑某些东西时遇到太多麻烦;如果你这样做了,freenode 上的#git 是一个很好的资源。所以,这应该没有太多麻烦,但我不知道如何做到这一切。