我还没有更新的问题,因为过去几天我能够工作真的很好,很容易与我的新回购:)
这里的帮助是什么,我到底做了:
在同一目录中初始化两个SVN回购。 (我不能在这个时候的rember,但有可能是一个“混帐初始化”在同一目录做,之前:
mkdir src && cd src
(not sure about this: git init)
git svn init --stdlayout --prefix=projA/ -RprojA file:///path/to/svn/repo/A
git svn init --stdlayout --prefix=projB/ -RprojB file:///path/to/svn/repo/B
的“--stdlayout”指SVN回购协议是在标准格式,主干,分支和标签在同一级别
“--prefix”用于分支名称。当我们执行“git branch -a”时,项目A中的所有SVN分支都有前缀“projA”(例如:projA/branch_name_of_A)。同样的事情是为B.
-R选项设置SVN仓库的名称,在git仓库里面(这是我们在引用时使用的名字到SVN存储库/项目)
file:/// path是SVN回购的路径,以及在这种情况下回购库中的项目。我使用“file://”,因为我使用了平面文件回购,没有服务器。对于SVN服务器,我确信它也可以与http://一起工作。
经过这一步,出于好奇,我看了一下src/.git/config文件。上面的两个命令创建了几个“svn-remote”部分,每个项目一个(-R选项)和一个名为“svn”的通用部分。我修改了条目,因此只会引用项目。每个引用都包含回购路径(提取)和标签/分支/主干的条目。如果你看一下这个文件,你就会明白需要改变什么。
在此之后,我取每个项目的内容,用
git svn fetch projA #the contents of project A repo are downloaded
git svn fetch projB #the contents of project B repo are downloaded
现在,运行过程中出现“混帐分支-a”从两个回购协议显示的所有分支机构,并且主分支(本地)。 “git branch -r”没有显示任何分支;可能是因为它们是“svn-remote”而不是“remote”
当前“主”分支指向第二个项目的主干。我决定摆脱它,因为从一个项目切换到另一个项目会导致问题。
我已经创建了两个新的分支指向每个项目的树干,然后去掉了“master”分支:
git checkout -b master_project_A projA/trunk
git checkout -b master_project_B projB/trunk
git branch -D master
而现在,对于“工作流”;对项目工作:
git checkout master_project_A #switch to project A
git svn rebase #check for any updates on SVN repo
git checkout -b work_on_A master_project_A #create a branch starting from the master of project A
work work work on work_on_A; commit, etc
git checkout master_project_A #go back to master of project A
git svn rebase #check again for any update on SVN repo
git checkout work_on_A #go back to the work branch
git rebase master_project_A #update branch with any changes from the master of project A
git checkout master_project_A #go back to the master of project A
git merge work_on_A #merge to the master of project A the changes from the work branch
git svn dcommit #commit changes to the SVN repo, in trunk, because master_project_A was pointing to its trunk
如果我想从SVN签现有的分支,我可以做到这一点:
git checkout -b work_on_branch projA/branch_name
work work work
git svn rebase #update any changes from projA/branch_name
git svn dcommit #commit updates back to the branch in the SVN repo
对于B项目,我可以做同样的事情。最后,我可以将项目A或B的内容放在同一个目录“src”中,并且可以从同一个git仓库访问SVN仓库中的两个项目! :D
我还没有弄清楚如何创建一个本地分支,然后把它推到SVN回购 - 我很接近,但它没有奏效。另外,知道命令“reset”(“git reset --hard projPrefix/branch”)可能会很有用,但是我用它打破了一些东西,所以最好在其他时间保留它。
我希望这可以帮助别人!
干杯,亚历克斯
你是什么原因svn库的混帐svn的克隆?你为什么不克隆到工作仓库? – hillu 2009-03-04 09:57:07
我试过了,但是我遇到了一些问题。我已经尝试了一遍,显然我越来越近 - 但现在有一些分支。 (这两个项目,A和B都使用标准svn布局,trunk + branches +标签,我必须在配置文件中进行一些修改) – Alex 2009-03-04 12:29:23