如何使用 svn-git (标准布局)然后使用 --bare 选项的 svn-clone 正确保留所有分支
我正在尝试将 svn 存储库移动到 git 存储库。我不想再使用 svn,所以我使用无元数据选项。我很好奇为什么在执行 git svn fetch 之后,只有对我的分支创建的远程引用。我正在使用以下命令创建存储库:
git svn init -s --username=$SVNUSER --no-metadata http://URLTOSVN/$REPO
git config svn.authorsfile ../$USERFILE
git svn fetch
运行 fetch 后,如果我查看我拥有的分支:
prompt$ git branch -a
* master
remotes/BRANCH_1
remotes/BRANCH_2
remotes/trunk
我需要 BRANCH_1 和 BRANCH_2 分支,但它似乎没有创建它们。现在,当我使用 --bare 选项克隆它时,我可以将它托管在我的中央存储库中,它会忽略那些远程引用,并且据我所知,我生成的 git 存储库不了解这些分支。我在生成的存储库中需要这些分支。我缺少什么?
I'm attempting to move an svn repository to a git repository. I don't want to use svn anymore so I am using the no-metadata option. I'm curious why, after doing git svn fetch there are only remote refs created to my branches. I'm creating the repo using:
git svn init -s --username=$SVNUSER --no-metadata http://URLTOSVN/$REPO
git config svn.authorsfile ../$USERFILE
git svn fetch
after running the fetch, if I look at the branches I have:
prompt$ git branch -a
* master
remotes/BRANCH_1
remotes/BRANCH_2
remotes/trunk
I need BRANCH_1 and BRANCH_2 branches but it doesn't seem to be creating them. Now when I clone this using the --bare option so I can host it in my central repo it ignores those remote refs and my resulting git repo has no knowledge of those branches as far as I can tell. I need those branches in my resulting repo. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着远程分支可用,但您当前没有将它们作为本地分支。您应该能够使用 git fetch 检索它们:
即,
这是我之前用于将 svn 存储库传输到 git 的 bash 脚本。这将为您在当前目录中运行的计算机上提供一个裸露的 git 存储库:
这还将保留您的 svn 日志历史记录。您可能需要摆弄连接参数,因为我实际上使用的是 svn+ssh,而不是 http。看看我导入并克隆的确实有分支的存储库,我看到这样的示例:
在您的裸存储库中,分支应该只有它们的名称。 ie:
但是我发现我能够创建一个名为remotes/branch1的分支,所以可能你实际上有一个名称奇怪的本地分支。您可以尝试使用以下命令进行切换:
This means the remote branches are available but you do not currently have them as local branches. You should be able to retrieve them with a git fetch:
i.e.
Here's a bash script I've used previously for transferring svn repos to git. This will give you a bare git repo on the machine it is run in the current directory:
That will also preserve your svn log history. You will probably need to fiddle with the connection parameters as I actually used svn+ssh, not http. Looking at a repo I imported and then cloned that did have branches I see examples like this:
In your bare repo the branches should just have their name. ie:
However I found I was able to create a branch named remotes/branch1, so it may be that you actually have local branches that are just weirdly named. You can try swicthing with: