我可以 git-svn 克隆具有多个标准目录布局的 svn 存储库吗
我有一个 SVN 存储库,其布局如下
项目1/主干
项目1/分支
项目1/标签
项目2/主干
项目2/分支
项目2/标签
。
出于多种原因,我想要一个 git-svn 存储库,它允许我处理这些项目中的任何一个,并同时从所有项目中获取/提交 这种事情可能吗?我知道我可以通过 git-svn 克隆整个内容,而不需要指定分支、标签和主干,但这样我就会失去使用 git 的很多优势。
I have an SVN repo with a layout like
project1/trunk
project1/branches
project1/tags
project2/trunk
project2/branches
project2/tags
etc.
For a number of reasons, I'd like a git-svn repo that allows me to work on any of these projects and fetch/dcommit from/to all of them at once. Is this kind of thing possible? I know I could just git-svn clone the whole thing without specifying branches, tags, and trunk, but then I'd lose a lot of the advantage of using git.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我就是这样做的。不过,可能还有更简单的方法。
选择第一个具有您想要使用的标准布局的项目,然后
git svn clone
它:git svnclone --stdlayout http://sample.com/svn/repository-name/project-namerepository-name
进入
repository-name
目录并编辑其.git/config
文件。您也可以使用 git-config 命令执行此操作,但我发现在文本编辑器中更容易。您将看到已为您的第一个项目定义的
[svn-remote "svn"]
部分。将svn-remote
重命名为比"svn"
更独特的名称,可能与您的项目名称相同。例如,[svn-remote "project-name"]
。按照第一个项目的模板,为每个项目创建更多的
[svn-remote "project-name"]
部分。给每个人一个独特的名字!您需要更改fetch
、branches
和tags
设置,以便为每个项目使用正确的 Subversion 目录名称。完成后,保存文件并运行
git svn fetch --fetch-all
。其他项目将作为远程项目提取到本地存储库中。要在项目之间切换
master
,请执行git reset --hard other-project-name/trunk
,就像您切换到任何其他项目一样远程 Subversion 分支。This is how I did it. There may be simpler ways, though.
Select the first project with the standard layout you'd like to work on and
git svn clone
it:git svn clone --stdlayout http://sample.com/svn/repository-name/project-name repository-name
Go into the
repository-name
directory and edit its.git/config
file. You could also do this withgit-config
commands, but I find it easier in a text editor.You'll see an
[svn-remote "svn"]
section already defined for your first project. Rename thesvn-remote
to something more unique than"svn"
, probably the same as your project name. E.g.,[svn-remote "project-name"]
.Make more
[svn-remote "project-name"]
sections for each project, following the template of the first one. Give each one a unique name! You'll need to change thefetch
,branches
, andtags
settings to use the correct Subversion directory names for each project.Once you're done, save your file and run
git svn fetch --fetch-all
. The other projects will be fetched as remotes in your local repository.To switch your
master
between projects, do agit reset --hard other-project-name/trunk
, just like if you were switching to work on any other remote Subversion branch.为了解决同时检查多个项目的问题,
git-new-workdir 可用于从同一个 git 存储库中检出多个工作目录,请参阅 https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir
To get around the issue of checking out multiple projects simultaneously,
git-new-workdir can be used to check out multiple working directories from the same git repository, see https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir