[英]git-svn merging when branches don't line up
I suspect this may simply be an impedance mismatch between git
and svn
, but I wanted to ask the SO community for advice. 我怀疑这可能只是
git
和svn
之间的阻抗不匹配,但我想向SO社区寻求建议。
I am working on a project that uses svn
for version control. 我正在使用
svn
进行版本控制的项目中。 That's not going to change, and I have no control over it. 这不会改变,我对此无能为力。 I've happily been doing my work on my branch using
git-svn
. 我很高兴一直在使用
git-svn
在分支上进行工作。 However, I ran into an odd problem related to the strange way the SVN project was set up. 但是,我遇到了一个与SVN项目的建立方式有关的奇怪问题。
In SVN, the project looks like this: 在SVN中,项目如下所示:
.git/config: .git / config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[svn-remote "svn"]
url = http://svn-repo
fetch = project/trunk:refs/remotes/trunk
branches = project/branches/*:refs/remotes/*
tags = project/tags/*:refs/remotes/tags/*
When the branches were created, they were created one level below trunk
. 创建分支时,它们是在
trunk
之下的一级创建的。 I had no control over this either. 我也对此无能为力。
When I try to merge from MyBranch
to trunk
, my tree merges one level up. 当我尝试从
MyBranch
合并到trunk
,我的树会向上合并一级。 That is, MyBranch/Dir1
has no relationship to trunk/Proj_Main/Dir1
. 也就是说,
MyBranch/Dir1
trunk/Proj_Main/Dir1
与trunk/Proj_Main/Dir1
没有关系。 In svn
natively, it does understand this relationship, and I can merge using svn
tools, but git
is lost. 在
svn
,它确实了解这种关系,我可以使用svn
工具合并,但是git
丢失了。
Is there a way I can tell git
that master
points to trunk/Proj_Main
instead of just trunk
? 有什么办法可以告诉
git
master
指向trunk/Proj_Main
而不是trunk
?
Edit the fetch line to something like: 将提取行编辑为以下内容:
fetch = project/trunk/Proj_Main:refs/remotes/trunk
That should do.... however , I don't know if you will have to fetch again from revision 1 for such a change to work correctly. 那应该可以...。 但是 ,我不知道您是否必须从修订版1再次获取该更改才能正常工作。
@eftshift0 had the right approach. @ eftshift0使用正确的方法。 Sometimes there is no salvaging a bad situation.
有时并没有挽救坏局面。 I made sure everything was sync'd with SVN and started over again.
我确保一切都与SVN同步,然后重新开始。
git svn clone -r<start>:HEAD http://svn-repo/project \
--prefix=mine/ \
--trunk=trunk/Proj_Main --branches=branches --tags=tags \
--no-minimize-url
Since this is a very mature SVN repo, and I don't care about history from 5 years ago, I limited the scope of my clone, for the sake of time. 由于这是一个非常成熟的SVN回购,并且我不在乎5年前的历史,因此为了节省时间,我限制了克隆的范围。
The --prefix
is based on advice in the git-svn docs . --prefix
基于git-svn docs中的建议 。
Rather than -s
or --stdlayout
, I explicitly specified how things were laid out in SVN. 我没有指定
-s
或--stdlayout
,而是明确指定了如何在SVN中进行布局。 Note that early attempts to apply this approach encountered a git-svn bug fetching, probably related to a deleted SVN branch. 请注意,早期尝试使用此方法的尝试遇到了git-svn错误获取,可能与已删除的SVN分支有关。 That's another reason for limiting the scope of the fetch.
这是限制获取范围的另一个原因。
The --no-minimize-url
is due to the fact that other repos exist at the server. --no-minimize-url
是由于服务器上存在其他存储库而导致的。 Without this switch, git-svn pushes up a level and considers all the repos in trying to resolve branches, merges, and such. 没有此开关,git-svn会提升级别并在尝试解析分支,合并等时考虑所有回购协议。 That was not a good thing for me.
对我来说那不是好事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.