git-svn - 克隆了一个分支,现在提交到另一个分支?

发布于 2025-01-02 09:56:36 字数 356 浏览 1 评论 0原文

我一直在使用 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 分支?是否可以 ?

I have been using git-svn to work remotely on a spike for a new feature. Now I want to commit my changes to SVN, but on a different SVN branch than the one I first cloned. How do I do that ?

The original branch has changed, and I am not ready to merge the two. I would like to create a new SVN branch from the original branch, and commit the changes I have in git.

I have a shallow clone of just the one SVN branch:

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

How do I commit my changes back to another SVN branch ? Is it possible ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江南月 2025-01-09 09:56:36

扩展 the.malkolm 的答案:

如果您查看 .git/config ,你会发现像 fetch = Branchs/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

Expanding on the.malkolm's answer:

If you look in .git/config, you'll find a line like fetch = branches/main:refs/remotes/git-svn. Add another similar line, referring to the name of the remote branch you want to commit to, and a name to give it locally (or, for the Subversion trunk, fetch = trunk:refs/remotes/trunk).

Then run git svn fetch. That'll download the history of the branch you've just added; feel free to limit the revisions it fetches if that's what you need.

Then rebase onto the new branch, and commit from there!

git rebase $(git merge-base remotes/git-svn MySpike) MySpike --onto remotes/newbranch
git svn dcommit
深陷 2025-01-09 09:56:36

当你成功配置了两个 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

After you managed to configure two svn branches (just modify .git/config file). Here is how to rebase all code you did on top of svn/original/branch in the branch named cool/feature to another svn branch svn/another/branch:

git rebase --onto svn/another/branch $(git merge-base svn/original/branch cool/feature) cool/feature
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文