我可以用git-svn克隆具有多个标准目录布局的svn存储库
我有一个布局类似
的SVN存储库project1/trunk
专案1/分支机构
project1/标签
project2/trunk
项目2/分支机构
project2/标签
等
I have an SVN repo with a layout like
project1/trunk
project1/branches
project1/tags
project2/trunk
project2/branches
project2/tags
etc.
出于多种原因,我想要一个git-svn仓库,该仓库可以让我从事任何这些项目,并一次从所有项目中提取/提交.这种事可能吗?我知道我可以git-svn克隆整个东西而无需指定分支,标签和主干,但是那样我就会失去使用git的很多优势.
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.
这就是我的方法.不过,可能有更简单的方法.
This is how I did it. There may be simpler ways, though.
-
选择要使用标准布局的第一个项目,然后
git svn clone
git svn clone --stdlayout http://sample.com/svn/repository-name/project-name仓库名称
进入 repository-name
目录并编辑其 .git/config
文件.您也可以使用 git-config
命令执行此操作,但是我发现在文本编辑器中更容易.
Go into the repository-name
directory and edit its .git/config
file. You could also do this with git-config
commands, but I find it easier in a text editor.
您将看到已经为第一个项目定义的 [svn-remote"svn"]
部分.将 svn-remote
重命名为比"svn"
更独特的名称,可能与您的项目名称相同.例如 [svn-remote"project-name"]
.
You'll see an [svn-remote "svn"]
section already defined for your first project. Rename the svn-remote
to something more unique than "svn"
, probably the same as your project name. E.g., [svn-remote "project-name"]
.
按照第一个模板的模板,为每个项目添加更多的 [svn-remote"project-name"]
部分.给每个人起一个独特的名字!您需要更改 fetch
, branches
和 tags
设置,以便为每个项目使用正确的Subversion目录名称.
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 the fetch
, branches
, and tags
settings to use the correct Subversion directory names for each project.
完成后,保存文件并运行 git svn fetch --fetch-all
.其他项目将作为本地存储库中的远程项目获取.
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.
要在项目之间切换 master
,请执行 git reset --hard other-project-name/trunk
,就像您要切换工作一样在其他任何远程Subversion分支上.
To switch your master
between projects, do a git reset --hard other-project-name/trunk
, just like if you were switching to work on any other remote Subversion branch.