git-svn - 克隆了一个分支,现在提交到另一个分支?
我一直在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
扩展 the.malkolm 的答案:
如果您查看
.git/config
,你会发现像fetch = Branchs/main:refs/remotes/git-svn
这样的行。添加另一个类似的行,引用您要提交到的远程分支的名称,以及在本地为其指定的名称(或者,对于 Subversion 主干,fetch = trunk:refs/remotes/trunk
)。然后运行 git svn fetch 。这将下载您刚刚添加的分支的历史记录;如果您需要的话,请随意限制它获取的修订。
然后重新定位到新分支,并从那里提交!
Expanding on the.malkolm's answer:
If you look in
.git/config
, you'll find a line likefetch = 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!
当你成功配置了两个 svn 分支后(只需修改 .git/config 文件)。以下是如何将名为 cool/feature 的分支中 svn/original/branch 上所做的所有代码变基到另一个 svn 分支 svn/another/branch :
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: