Introduction
We are moving from Git to SVN using git-svn
.
We have a single SVN repository with a large directory tree. A project links to other subprojects using relative paths. The simplified example below has a MainProject
that is dependent on SharedProject1
and SharedProject2
SVN
└── trunk
├── MainProject
├── SharedProject1
└── SharedProject2
Moving over to Git, we will have one repository per project. We will handle dependencies using git-subtree
. So the structure for the MainProject
repository would look like:
MainProject
└── Depend
├── SharedProject1
└── SharedProject2
How the git -> svn move is performed
Each project is cloned to Git repositories using:
git svn clone http://server/svn --trunk="trunk/MainProject" MainProject
git svn clone http://server/svn --trunk="trunk/SharedProject1" SharedProject1
git svn clone http://server/svn --trunk="trunk/SharedProject2" SharedProject2
In the MainProject
we add the SharedProject's with git-subtree:
git subtree add --prefix "Depend/SharedProject1" path/to/SharedProject1 master --squash
git subtree add --prefix "Depend/SharedProject2" path/to/SharedProject2 master --squash
After changing the links in MainProject, everything works fine!
The problem with git svn rebase
When some of our developers updates the MainProject
in the SVN repository, I want to add the changes to the Git repository for MainProject using:
git svn rebase
But I get the following error:
First, rewinding head to replay your work on top of it...
Applying: Squashed 'Depend/SharedProject1/' content from commit fdabd7b
Applying: Squashed 'Depend/SharedProject2/' content from commit 38e8c6f
...
Falling back to patching base and 3-way merge...
Auto-merging Properties/AssemblyInfo.cs
CONFLICT (add/add): Merge conflict in Properties/AssemblyInfo.cs
Failed to merge in the changes.
Patch failed at 0002 Squashed 'Depend/SharedProject2/' content from commit 38e8c6f
...
rebase refs/remotes/trunk: command returned error: 1
Both SharedProject1
and SharedProject2
(but not MainProject
) has a file Properties/AssemblyInfo.cs
that git seems to try to merge even though they are not in the same folder.
What am I doing wrong, and how can I get it to work properly?
I have another problem, may be related to your problem (yes, after years has passed). On my side the git svn rebase
tries to rebase the root of a subree directly into the root of the main project (as there was no --prefix
for the subree or it does ignore it).
That happens after these steps:
'
From https://...
! [rejected] trunk -> master (non-fast-forward)
+ 834b7b2...794c965 trunk -> origin/trunk (forced update)
.git\\svn\\refs\\remotes\\origin\\trunk
and refetching the svn: git svn fetch
(this fix basically works) git svn rebase
the main project root is messed up and contains the root of a subtree. Seems in your case you have 2 subtrees, where the git tries to merge a file to the same directory (main project root) twice.
I don't know why, but seems git-svn
somehow either misses information about subtree prefixes or does not take it into account.
To fix that i have to call git push origin master:trunk
before the git svn rebase
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.