git clone of git-svn tree?
我有一个\\'git-svn \\'工作树。我想从中克隆一个" pure " git repo,然后使用git push / pull在git-svn树和git树之间移动更改,同时还使用\\'git svn dcommit / rebase \\ '在git-svn树和基于它的SVN存储库之间移动更改。
这对于使用git方法在git树之间来回移动似乎还可以,但是,一旦我与git-svn树中的SVN repo交互,事情就会变得很奇怪-要么我得到错误在git树之间推动或拉动时,或者我在git-svn树中丢失提交,或出现其他奇怪情况。
这种类型的SVN <-> git-svn <-> git工作流是否完全受支持,还是我应该退出这棵树?
我为某些项目设置了桥接设置,但这只是从git到svn的一种方式(提供git master分支的公共只读SVN镜像)。但是,由于它工作正常,因此无论如何都可能会帮助您或在双向方案中为您指明正确的方向,因为我认为是git-> svn会引起问题,而不是svn-> git:
我的单向场景:github上现有的git存储库,需要git master分支的只读svn镜像
-
在服务器上创建并初始化目标Subversion存储库:
1
2
3
4svnadmin create svnrepo
mkdir trunk
svn import trunk svn://yoursvnserver/svnrepo
rmdir -rf trunk -
创建混合的Git-Svn结帐并初始化Subversion存储库
1
2
3
4
5
6
7
8
9
10
11
12git svn clone svn://yoursvnserver/svnrepo/trunk
cd trunk
git remote add github git://github.com/yourname/repo.git
git fetch github
git branch tmp $(cat .git/refs/remotes/github/master)
git tag -a -m"Last fetch" last tmp
INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1)
git checkout $INIT_COMMIT .
git commit -C $INIT_COMMIT
git rebase master tmp
git branch -M tmp master
git svn dcommit --rmdir --find-copies-harder -
更新镜像
1
2
3
4
5
6
7git fetch github
git branch tmp $(cat .git/refs/remotes/github/master)
git tag -a -m"Last fetch" newlast tmp
git rebase --onto master last tmp
git branch -M tmp master
git svn dcommit --rmdir --find-copies-harder
mv .git/refs/tags/newlast .git/refs/tags/last
这两个来自googlecode的文章可能也有帮助:
- 从Git导入
- 导出到Git
- 在Google Code Hosting中使用Git
- 使用Git在Google Code项目上进行开发
可能引起您麻烦的一件事是,
根据我所看到的,由于SVN表示合并的方式,因此git-svn不支持此工作流,也不支持。
就像我在#git上经常说的那样:
git-svn is like a flying car. Everybody wants a flying car, until they realize a flying car is pretty bad as either a car or a plane.
真正的解决方案是尽快完全摆脱SVN。使用git-svn进行一次迁移,然后将所有人转移。 Git并不难学习。
如果您能够将自定义钩子安装到Subversion存储库中,请考虑使用SubGit。
SubGit是服务器端解决方案,可自动同步SVN和Git存储库。为了安装SubGit,请执行以下操作:
1 2 3 4 5 6 7 8 | $ subgit configure $SVN_REPOS $ # Adjust $SVN_REPOS/conf/subgit.conf $ # to specify your branches and tags $ # Adjust $SVN_REPOS/conf/authors.txt $ # to introduce svn author names to their git counterparts $ subgit install $SVN_REPOS $ ... $ INSTALLATION SUCCESSFUL |
此刻,SubGit已安装了由每个
另请参阅与git-svn的比较。
使用git和git-svn 1.7.1,看来我刚刚做的测试似乎还可以。
1 2 | git svn init [url] git svn fetch |
然后必须创建并签出一个虚拟分支,以便能够推送到主分支。
1 | git checkout -b dummy |
然后可以将其(
返回git svn repo:
1 2 | git checkout master git svn dcommit |
将提交所有已推送的git commit。