简体   繁体   English

GIT SVN:获取重新创建的SVN分支,没有错误的合并父级

[英]GIT SVN: fetching a recreated SVN branch without the wrong merge parent

I have the following situation with my upstream svn repository: 我的上游svn存储库有以下情况:

I created an svn branch and did some work on it which led to a really convoluted history. 我创建了一个svn分支,并在其上做了一些工作,这导致了一个非常复杂的历史。 So I deleted it again, retaining the git commits, which allowed me to clean up the history quite nicely. 所以我再次删除了它,保留了git提交,这让我可以很好地清理历史。

Once I had my patch series ready, I recloned my branch using svn copy , followed by a git svn fetch . 一旦我准备好补丁系列,我使用svn copy克隆了我的分支,然后是git svn fetch The idea was, that I would then rebase the cleaned up history onto the new svn branch, so that I could easily publish it with git svn dcommit . 我的想法是,然后我将清理后的历史记录重新修改为新的svn分支,以便我可以使用git svn dcommit轻松发布它。

However, git svn fetch did not do what I expected. 但是, git svn fetch并没有达到我的预期。 This is what I expected (fake git log --oneline --decorate --graph output): 这就是我的预期(假git log --oneline --decorate --graph输出):

* xxxxxxx (svn-branch)
* xxxxxxx (svn-parent-branch)
...
somewhere further down, unrelated to the above
* xxxxxxx (old-svn-branch-head)

But this is what I got: 但这就是我得到的:

* xxxxxxx (svn-branch)
|\
| * xxxxxxx (svn-parent-branch)
|
* xxxxxxx (old-svn-branch-head)

As you see, git svn fetch completely ignored the fact that the svn branch was deleted, mapping the recreating svn commit to a merge commit in git . 如您所见, git svn fetch完全忽略了svn分支被删除的事实,将重新创建的svn提交映射到git的合并提交。 Now, I wouldn't fuss about this, if this were of no consequence, but unfortunately, the wrong connection confuses git 's merge algorithms, creating bogus merge conflicts when rebasing across the new branch base commit. 现在,我不会对此大惊小怪,如果这不重要,但不幸的是,错误的连接会混淆git的合并算法,在新的分支基础提交中进行重新定位时会产生虚假的合并冲突。

So my question is: How can I entice git svn fetch to not link up the new branch base commit with the wrong parent, or somehow fix my git repo in a way that I retain the ability to publish my stuff with git svn dcommit ? 所以我的问题是:我怎么能诱使git svn fetch没有将新的分支基础提交与错误的父级链接,或以某种方式修复我的git repo,我保留了使用git svn dcommit发布我的东西的能力? Of course, I can always delete the whole thing again, and create a new svn branch with a different name, but I was wondering whether a better solution exists. 当然,我总是可以删除整个事情,并创建一个具有不同名称的新svn分支,但我想知道是否存在更好的解决方案。

I encountered a similar situation and still couldn't find a way to turn off this behavior ( --no-follow-parent turns off the whole branch tracking, which is not what I want). 我遇到了类似的情况,仍然无法找到关闭此行为的方法( - --no-follow-parent关闭整个分支跟踪,这不是我想要的)。

I ended up fixing history with git replace --graft . 我最终用git replace --graft来修复历史。 It creates a replacement commit and keeps its children unchanged . 它创建一个替换提交并保持其子项不变 After the replace (ex. git replace --graft svn-branch svn-parent-branch ) this is what you see: 在替换之后(例如git replace --graft svn-branch svn-parent-branch )这就是你看到的:

* svn-branch
|
* svn-parent-branch
...
* old-svn-branch-head

You can still see the original commit with gitk --all option. 您仍然可以使用gitk --all选项查看原始提交。

* svn-branch (replacement)
| 
| * svn-branch (original)
|/|
* |  svn-parent-branch
| |
| * old-svn-branch-head
...

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

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