简体   繁体   English

如何使用git-svn将svn分支集成到git分支中?

[英]How to integrate svn branches into git branches with git-svn?

i have not much svn experience but i am used to work with git. 我没有多少svn经验,但是我习惯于git。

I have the following svn repository structure and revisions. 我有以下svn存储库结构和修订。

https://server/svn/solution/trunk/solution.sln @r100 https://server/svn/solution/trunk/solution.sln @ r100
https://server/svn/solution/trunk/project1/project1.csproj @r150 https://server/svn/solution/trunk/project1/project1.csproj @ r150
https://server/svn/solution/trunk/project2/project2.csproj @ r160 https://server/svn/solution/trunk/project2/project2.csproj @ r160

https://server/svn/solution/branches/solution.sln @r100 https://server/svn/solution/branches/solution.sln @ r100
https://server/svn/solution/branches/project1/project1.csproj @r200 https://server/svn/solution/branches/project1/project1.csproj @ r200
https://server/svn/solution/branches/project2/project2.csproj @ r350 https://server/svn/solution/branches/project2/project2.csproj @ r350

When i clone the repository 当我克隆存储库时

git svn clone https://server/svn/solution --stdlayout git svn克隆https:// server / svn / solution --stdlayout

I get everything 我什么都有

(master)$ git branch -a  
* master  
  remotes/project1  
  remotes/project2  
  remotes/trunk  

When i want to create a local branch for a remote one 当我想为远程分支创建本地分支时

(master)$ git checkout -b local-project1 project1

all i get when i checkout the branch is project1. 当我结帐分支时,我得到的全部是project1。 The branch does not contain anything from 该分支不包含来自

https://server/svn/solution/branches/solution.sln @r100 https://server/svn/solution/branches/solution.sln @ r100

To solve the problem i tried the following: 为了解决这个问题,我尝试了以下方法:

(local-project1)$ git checkout master
Switched to branch 'master'.
(master)$ git branch local-project1 -D
Deleted branch local-project1 (was 1111a11).
(master)$ git checkout -b local-project1
Switched to new branch 'local-project1'.
(local-project1)$ pwd
/c/workingcopies/solution
(local-project1)$ cd project1
(local-project1)$ pwd
/c/workingcopies/solution/project1
(local-project1)$ git branch --set-upstream local-project1 remotes/project1
Branch local-project1 set up to track local ref refs/remotes/project1.
(local-project1)$ git svn fetch
(local-project1)$ git reset --hard ae8e9b1a ;# go to last commit of the remote branch

The fetch gets the last revision from the branch in the repository and the HEAD is set to the last commit but i still only get project1 in the branch, not the solution. 提取从存储库中的分支获取最新修订版本,并且HEAD设置为最后一次提交,但是我仍然仅在分支中获取project1,而不是解决方案。 Any advice and help is appreciated. 任何建议和帮助表示赞赏。

The problem is that you do not have a standard svn layout. 问题是您没有标准的svn布局。 A standard layout would have directories under branches for each branch, like so. 像这样,标准布局将在每个分支的分支下具有目录。

repo/
  +-- trunk
  |     +-- solution.sin
  |     +-- project1/project1.csproj
  |     +-- project2/project2.csproj
  +-- branches/
        +-- branch01/
              +-- solution.sin
              +-- project1/project1.csproj
              +-- project2/project2.csproj

You instead have a trunk and a branch called "branches" located in the same directory as trunk. 相反,您有一个主干和一个与“主干”位于同一目录中的名为“分支”的分支。

I'm not sure if git can be told to handle this properly. 我不确定git是否可以正确处理。 I have some ideas: You could edit .git/config to make git look for a branch in the topmost directory, but then it might be confused when it tries to make a branch called trunk while it already has a trunk. 我有一些想法:您可以编辑.git / config,使git在最顶层目录中查找分支,但是当它试图创建一个已经有主干的分支称为trunk时,可能会感到困惑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM