git-svn提交错误的分支/如何通过git-svn合并svn分支 [英] git-svn commits to wrong branch / how to merge svn branch via git-svn

查看:144
本文介绍了git-svn提交错误的分支/如何通过git-svn合并svn分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SVN仓库,使用 - stdlayout 选项(当时,仓库为空)检出了git-svn。

I have a SVN repository which I checked out with git-svn, using the --stdlayout option (at that time, the repo was empty).

然后我在主分支上工作了一段时间。当使用 git svn dcommit 时,它会svn提交我的更改到 https://my.host/repo/trunk 喜欢它。

I then worked on the master branch for a while. When using git svn dcommit, it would svn-commit my changes to https://my.host/repo/trunk like it should.

在某些时候,我用git创建了一个名为算术的分支。后来我想在svn中创建这个分支,所以我做了一个 git svn branch arithmetics ,然后一个 git分支--set-upstream arithmetics remotes /算术建议由网站。我想这是出错的地方,因为我收到了有关 - set-upstream 被弃用的警告。

At some point I created a branch named "arithmetics" with git. Later I wanted to create that branch in svn too, so I did a git svn branch arithmetics and then a git branch --set-upstream arithmetics remotes/arithmetics as suggested by a website. I suppose this is where things went wrong, as I got a warning about --set-upstream being deprecated.

当调用 git svn dcommit 时,它会提交给 https://my.host/repo/branches/arithmetics , 到现在为止还挺好。但是后来我注意到,当我尝试将分支合并到master中时,无论git存储库中当前检出的分支如何, dcommit 都会提交给该分支。

When calling git svn dcommit, it would commit to https://my.host/repo/branches/arithmetics, so far so good. But then I noticed, that dcommit would commit to that branch regardless of the currently checked out branch in the git repository, when I tried merging the branch back into master.

我甚至尝试从svn创建一个新的克隆,将分支合并到主目录中。我也尝试使用 git checkout -b local / trunk remotes / trunk 明确地检出 trunk ,然后将分支合并到然后 git svn dcommit 。它会一直提交给分支。

I even tried creating a new clone from svn, merging the branch into master there. I also tried checking out trunk explicitly with git checkout -b local/trunk remotes/trunk, then merging the branch into that and then git svn dcommit. It would always commit to the branch again.

我该如何解决这个问题?

How can I fix this?

code> git rebase 用于合并,因为我读过,合并提交对git-svn有问题,所以我没有任何这些。

PS: I used git rebase for merging, as I read, that merge-commits were problematic with git-svn, so I don't have any of those.

推荐答案

你不能将分支提交给SVN仓库,因为Git和SVN有完全不同的分支概念。与git合并,然后调用dcommit将线性化您的历史记录(与rebase完全相同),然后推送到当前签出的分支。

You cannot dcommit git branches to an SVN repository, because Git and SVN have totally different notions of branches. Merging with git and then calling dcommit will linearize your history (quite the same as with rebase) and then push to the currently checked out branch.

以下是 git svn

Here's the important part from the manpage of git svn:


MERGE TRACKING

虽然git svn可以跟踪复制历史记录(包括分支和标签),它采用标准布局的
仓库,但它还不能代表git内部发生在git上游的合并
历史记录到SVN用户。因此,
建议用户在git
内保持历史尽可能线性,以减轻与SVN的兼容性(请参阅下面的CAVEATS部分)。

MERGE TRACKING
While git svn can track copy history (including branches and tags) for repositories adopting a standard layout, it cannot yet represent merge history that happened inside git back upstream to SVN users. Therefore it is advised that users keep history as linear as possible inside git to ease compatibility with SVN (see the CAVEATS section below).

另外, 警告 部分有专门针对您的问题的段落:

Also, the caveats section has a paragraph dedicated to your problem:


运行git merge或git pull不建议在您计划
的分支上提交,因为Subversion用户无法看到您创建
的任何合并。此外,如果你从一个SVN分支的
镜像的git分支中合并或拉出,dcommit可能会提交到错误的分支。

Running git merge or git pull is NOT recommended on a branch you plan to dcommit from because Subversion users cannot see any merges you’ve made. Furthermore, if you merge or pull from a git branch that is a mirror of an SVN branch, dcommit may commit to the wrong branch.

如果你这样做合并,请注意以下规则:git svn dcommit将尝试
在位于

If you do merge, note the following rule: git svn dcommit will attempt to commit on top of the SVN commit named in

git log --grep=^git-svn-id: --first-parent -1


这篇关于git-svn提交错误的分支/如何通过git-svn合并svn分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆