2016-08-12 65 views
2

因此,使用Subversion镜像(SubGit)与最新的BitBucket(4.8.3)。主人有两个变化。一个是直接制作的,一个是从一个功能分支合并而来的。当推变化时,得到一个SubGit错误:Jira颠覆镜像/ SubGit远程错误推

[email protected] MINGW64 /c/projects/repos/loct-demo (master) 
$ git push 
Total 0 (delta 0), reused 0 (delta 0) 
remote: error: The following ref update is disallowed: 
remote: error: refs/heads/master: leads to replacement of SVN branch 'trunk' 
remote: error: 
remote: error: You can allow branch replacements by setting svn.allowBranchReplacement = true in SubGit configuration file. 
remote: Fetching revisions from SVN repository: 
remote: up to date 
remote: Sending commits to SVN repository: 
To http://[email protected]:7990/scm/loct/loct-demo.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to 'http://[email protected]:7990/scm/loct/loct-demo.git' 

我确信我已经在过去做过,它工作得很好。我会尝试恢复并重新做到这一点,但只是想知道其他人是否看到了这个错误,并知道它的意思。

感谢,

布拉德

+0

重新设置git并重新执行更改似乎可以解决问题。不知道为什么我首先收到这个问题。将试着重现与功能 - >提交 - >合并 - >推。 – BradW

回答

1

与SubGit版本3.2.1和SVN镜像介绍此错误消息插件3.3.0版本。

SubGit/SVN Mirror拒绝在Subversion存储库中导致分支替换的推送操作。基本上有两种情况,当Git变化可能会导致SVN端的替换:

  1. 强制推送。

    当一个人强行推送非快进更新时,SubGit/SVN Mirror没有什么可做的,只能删除当前版本的分支并从一些较旧版本重新创建它,因为这正是非快进更新确实:从分支提示以外的提交中继续分支历史记录。

  2. 从一个分支快速合并到另一个分支。

    当一个创建一个新的分支foomaster

    $ git checkout -b foo 
    $ git commit -am 'fix foo' 
    [foo ca3caf9] fix foo 
    

    然后推动该分支到SubGit镜:

    $ git push origin foo 
    ... 
    Sending commits to SVN repository: 
        remote: ca3caf9 => r10 branches/foo 
    

    它获取ca3caf9映射到branches/[email protected]

    最后一个分支合并回foomaster

    $ git checkout master 
    $ git merge foo 
    Updating 0e39ad2..ca3caf9 
    Fast-forward 
    

    注意到更新中...快进消息?这意味着git mergemaster上找不到任何新的提交,因此不需要创建合并提交,即git merge只是将master指针从较早的提交0e39ad2移动到了较新的提交ca3caf9。当一个人推到master镜SubGit

    发生什么事:

    $ git push origin master 
    

    SubGit发现是master0e39ad2映射到[email protected]ca3caf9映射到branches/[email protected]更新。没有任何SubGit可以做但删除trunk并从branches/[email protected]重新创建它,这显然导致替换trunk

因此,我们确信,SubGit不能取代这两个场景分支,除非SubGit管理员明确设置以下配置选项:

$ edit REPO/subgit/config 
... 
[svn] 
    allowBranchReplacement = true 
... 
$ subgit install REPO 

不过,我建议你保持svn.allowBranchReplacement设置为false并遵循这些最佳做法,以避免原始问题中报告的错误消息:

  • 永不强制推动任何东西倾向于合并,将分支变更还原而不是覆盖它们。

  • 当合并一个分支到另一个添加--no-ff选项:它迫使git merge创建一个合并提交时,它宁愿做一个快进更新,否则:

    $ git merge --no-ff foo 
    

UPDATE:

如果您使用的是SVN Mirror附加组件,您可以在分支机构映射选项卡上指定svn.allowBranchReplacement选项:

Branches Mapping

的文本字段应如下所示:

[svn] 
    trunk = ... 
    ... 
    allowBranchReplacement = true 

,然后点击为了激活这个新的设置应用更改按钮。

+0

我正在使用BitBucket Svn镜像(在Windows上),似乎没有任何选项可以在Web UI中设置此参数。问题1:我应该将值添加到subgit \ config或subgit \ stash.config吗?问题2:我在服务器上似乎没有subgit.exe - 如何让参数生效? – Andy

+0

@您可以将此选项添加到*分支映射*选项卡的文本字段中,然后单击“应用更改”按钮。请参阅我的更新了解更多详情。 – vadishev