【问题标题】:git-svn - cloned a single branch, now dcommit to another branch?git-svn - 克隆了一个分支,现在 dcommit 到另一个分支?
【发布时间】:2012-02-05 11:26:34
【问题描述】:

我一直在使用 git-svn 远程工作,以获取新功能。现在我想将我的更改提交到 SVN,但在 不同于我第一次克隆的那个 SVN 分支上。我怎么做 ?

原来的分支已经变了,我还没准备好将两者合并。我想从原始分支创建一个新的 SVN 分支,并提交我在 git 中所做的更改。

我只有一个 SVN 分支的浅层克隆:

git svn clone -r:HEAD svn://***/branches/main
git branch MySpike
git checkout MySpike
// Did some work, a lot of commits.

如何将我的更改提交回另一个 SVN 分支?是否可以 ?

【问题讨论】:

  • 我会说 1:使用 git-svn 检查目标 SVN 分支并将其设为您的工作副本(如果不存在则创建它)。 2: git-merge 或 git-rebase 你本地的 MySpike 分支到跟踪分支。 2b(可选):删除 MySpike 分支,因为在您 dcommit 后所有哈希值都发生了变化,git 将不再能够判断它已被合并。 3: dcommit 跟踪分支到 SVN repo。

标签: git svn git-svn


【解决方案1】:

扩展the.malkolm的回答:

如果您查看.git/config,您会发现类似fetch = branches/main:refs/remotes/git-svn 的行。添加另一个类似的行,引用您要提交到的远程分支的名称,以及在本地给它的名称(或者,对于 Subversion 主干,fetch = trunk:refs/remotes/trunk)。

然后运行git svn fetch。这将下载您刚刚添加的分支的历史记录;如果您需要,请随意限制它获取的修订。

然后变基到新分支,并从那里提交!

git rebase $(git merge-base remotes/git-svn MySpike) MySpike --onto remotes/newbranch
git svn dcommit

【讨论】:

    【解决方案2】:

    在你成功配置了两个 svn 分支之后(只需修改 .git/config 文件)。以下是如何将您在名为 cool/feature 的分支中的 svn/original/branch 之上执行的所有代码重新定位到另一个 svn 分支 svn/another/branch

    git rebase --onto svn/another/branch $(git merge-base svn/original/branch cool/feature) cool/feature
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      • 2017-06-17
      • 2021-10-01
      相关资源
      最近更新 更多