I have a repository whose layout is like this:
我有一个存储库,其布局如下:
trunk/ projectA projectB branches/ projectA-1.0 projectB-1.0 tags/ projectA-1.0.1 projectB-1.0.1
I want to convert them to separate git repositories with the trunk/projectA as the top-level directory and all it's branches as git branches.
我想将它们转换为单独的git存储库,其中trunk / projectA作为*目录,所有它的分支作为git分支。
Whenever I try to specify a git svn init
like git svn init -T trunk/projectA -b branches -t tags http://svn.example.com
, the follow-up git svn fetch
fails mysteriously on different revisions. Sometimes it gets all the way to 200, sometimes it stops.
每当我尝试指定一个git svn init,如git svn init -T trunk / projectA -b branches -t tags http://svn.example.com时,后续git svn fetch在不同的版本上神秘地失败。有时它会一直到200,有时会停止。
My current thinking is that I should create a git repository that mirrors the whole subversion repository as a single entity with subdirectories for each project. Then I would use git-filter-branch
to rewrite the subdirectories to the root of the project.
我目前的想法是,我应该创建一个git存储库,它将整个subversion存储库镜像为一个单独的实体,每个项目都有子目录。然后我会使用git-filter-branch将子目录重写到项目的根目录。
However, I'm not sure how to get the branches to behave like I want using git-filter-branch
and.
但是,我不确定如何让分支表现得像我想要使用git-filter-branch和。
Also it would be ideal to create a single git repo that has different branches for the "trunk" of each project, I would have no problem not really having a master in this case.
另外,理想的做法是为每个项目的“主干”创建一个具有不同分支的单个git仓库,在这种情况下我没有问题没有真正拥有主人。
2 个解决方案
#1
Did you consider svn2git in order to import your svn into a git repository ?
您是否考虑使用svn2git将svn导入git存储库?
It is better than git svn clone
because if you have this code in svn:
它比git svn clone更好,因为如果你在svn中有这个代码:
trunk
...
branches
1.x
2.x
tags
1.0.0
1.0.1
1.0.2
1.1.0
2.0.0
git-svn
will go through the commit history to build a new git repo.
It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
So after importing this project, you would get:
git-svn将通过提交历史记录来构建一个新的git repo。它将所有分支和标签导入为远程svn分支,而你真正想要的是git-native本地分支和git标记对象。因此,在导入此项目后,您将获得:
$ git branch
* master
$ git branch -a
* master
1.x
2.x
tags/1.0.0
tags/1.0.1
tags/1.0.2
tags/1.1.0
tags/2.0.0
trunk
$ git tag -l
[ empty ]
After svn2git is done with your project, you'll get this instead:
在你的项目完成svn2git后,你会得到这个:
$ git branch
* master
1.x
2.x
$ git tag -l
1.0.0
1.0.1
1.0.2
1.1.0
2.0.0
Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo.
最后,它确保master的HEAD与svn repo的当前主干相同。
So in your case, it would give you actual git branches to apply git-filter-branch
.
所以在你的情况下,它会给你实际的git分支来应用git-filter-branch。
#2
What I ended up doing was cloning the root of the repository and copying that new git repo for each project and rearranging things. It wasn't clean or pretty, but it was legacy code that I no longer need to look at very often.
我最终做的是克隆存储库的根并为每个项目复制新的git repo并重新排列。它不干净或漂亮,但它是遗留代码,我不再需要经常查看。
#1
Did you consider svn2git in order to import your svn into a git repository ?
您是否考虑使用svn2git将svn导入git存储库?
It is better than git svn clone
because if you have this code in svn:
它比git svn clone更好,因为如果你在svn中有这个代码:
trunk
...
branches
1.x
2.x
tags
1.0.0
1.0.1
1.0.2
1.1.0
2.0.0
git-svn
will go through the commit history to build a new git repo.
It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
So after importing this project, you would get:
git-svn将通过提交历史记录来构建一个新的git repo。它将所有分支和标签导入为远程svn分支,而你真正想要的是git-native本地分支和git标记对象。因此,在导入此项目后,您将获得:
$ git branch
* master
$ git branch -a
* master
1.x
2.x
tags/1.0.0
tags/1.0.1
tags/1.0.2
tags/1.1.0
tags/2.0.0
trunk
$ git tag -l
[ empty ]
After svn2git is done with your project, you'll get this instead:
在你的项目完成svn2git后,你会得到这个:
$ git branch
* master
1.x
2.x
$ git tag -l
1.0.0
1.0.1
1.0.2
1.1.0
2.0.0
Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo.
最后,它确保master的HEAD与svn repo的当前主干相同。
So in your case, it would give you actual git branches to apply git-filter-branch
.
所以在你的情况下,它会给你实际的git分支来应用git-filter-branch。
#2
What I ended up doing was cloning the root of the repository and copying that new git repo for each project and rearranging things. It wasn't clean or pretty, but it was legacy code that I no longer need to look at very often.
我最终做的是克隆存储库的根并为每个项目复制新的git repo并重新排列。它不干净或漂亮,但它是遗留代码,我不再需要经常查看。