如何让 git-svn 使用特定的 svn 分支作为远程存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/192736/
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 05:52:34  来源:igfitidea点击:

How do I make git-svn use a particular svn branch as the remote repository?

gitsvnrepositorybranchgit-svn

提问by Hank Gay

A word of warning: I'm a n00b to gitin general. My team uses feature branches in svn, and I'd like to use git-svnto track my work on a particular feature branch. I've been (roughly) following Andy Delcambre's postto set up my local gitrepo, but those instructions seem to have led gitto pick the svnbranch that had changed most recently as the remote repository; the problem is that's not the branch I care about. How do I control which branch git-svnuses? Or am I approaching this completely wrong?

一句警告:git总的来说,我是一个n00b 。我的团队在 中使用功能分支svn,我想用它git-svn来跟踪我在特定功能分支上的工作。我一直(大致)按照Andy Delcambre 的帖子来设置我的本地存储git库,但这些说明似乎导致git选择svn最近更改的分支作为远程存储库;问题是那不是我关心的分支。如何控制git-svn使用哪个分支?或者我接近这个完全错误?

UPDATE: I did use the -T, -b, and -toptions (in my case because the svnrepo has multiple projects, but I want the gitrepo to contain only the project I'm working on).

更新:我确实使用了-T,-b-t选项(在我的情况下,因为svnrepo 有多个项目,但我希望gitrepo 只包含我正在处理的项目)。

采纳答案by Hank Gay

Muchas gracias to Bart's Blog for this handy reference for svn branches in git. Apparently all I needed was to specify a remote branch when creating the gitbranch, e.g.,

非常感谢 Bart 的博客,为 git 中的 svn 分支提供了方便的参考。显然,我只需要在创建分支时指定一个远程git分支,例如,

git checkout -b git-topic-branch-foo foo

where foois the name of the remote branch.

foo远程分支的名称在哪里。

回答by Sam Mulube

You might also have a look at this: git-svn is a gateway drug - robby on rails.

您可能还看看这个:git-svn 是一个网关药物抢劫在 rails

I used something like this when I needed to make sure that my local branch was pointing to the correct remote svn branch:

当我需要确保我的本地分支指向正确的远程 svn 分支时,我使用了这样的东西:

git branch -r

to get the name of the remote branch I want to be tracking. Then

获取我要跟踪的远程分支的名称。然后

git reset --hard remotes/svn-branch-name

to explicitly change my local branch to point to a different remote branch.

显式更改我的本地分支以指向不同的远程分支。

回答by android.weasel

I needed to run 'git svn fetch' first, since the branch I wanted to associate with had been created after my git client.

我需要先运行“git svn fetch”,因为我想关联的分支是在我的 git 客户端之后创建的。

回答by Greg Hewgill

I use git-svn but I haven't used the features that interoperate with SVN branches. Having said that, I notice that the tutorial you were following didn't use the -T, -b, -toptions to git svn init. These options tell git-svn what the upstream trunk/branches/tags directories are named, which might be important in your situation.

我使用 git-svn 但我没有使用与 SVN 分支互操作的功能。话虽如此,我注意到您所关注的教程没有使用-T、-b、-t选项来 git svn init。这些选项告诉 git-svn 上游主干/分支/标签目录的名称,这在您的情况下可能很重要。