git-svn:在 svn rebase 后保留单个合并提交

发布于 2024-10-23 19:52:35 字数 520 浏览 2 评论 0原文

我按照这种模式使用 git-svn 将功能分支中的代码签入到 Subversion:

git checkout master
git svn rebase
git checkout feature-branch
git rebase master
git checkout master
git merge --no-ff feature-branch
git commit --amend
git svn dcommit

(master 是我的远程 Subversion 跟踪分支)

这会在 master 上创建单个合并提交(无论我在功能上完成了多少次 git 提交) -branch),我可以将其签入 Subversion。

然而,在我将功能分支合并到 master 后,有人将代码检查到 Subversion,当我执行命令 git svn rebase 时,会应用新的更改,并且功能分支中的每个单独提交都会应用到顶部。此时,我不再有单个合并提交,而是在 master 中的功能分支上执行的每个提交。

处理这个问题的最佳方法是什么?

I am following this pattern to check in my code in feature-branch to Subversion with git-svn:

git checkout master
git svn rebase
git checkout feature-branch
git rebase master
git checkout master
git merge --no-ff feature-branch
git commit --amend
git svn dcommit

(master is my remote Subversion tracking branch)

This creates a single merge commit on master (regardless of how many git commits I have done on feature-branch) which I can check into Subversion.

However, someone checks code into Subversion after I merge feature-branch into master, when I execute the command git svn rebase the new changes are applied and each individual commit from feature-branch is applied on top. At this point I no longer have a single merge commit but every commit that I performed on feature-branch in master.

What is the best way to deal with this?

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

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

发布评论

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

评论(2

世界如花海般美丽 2024-10-30 19:52:35

我是这样做的:

git checkout feature-branch
git rebase -i HEAD~10  # squash commits in my editor
git svn rebase  # make sure I have the latest code
git svn dcommit
git checkout master
git svn rebase # now the feature-branch squashed commit is visible on master

Here is how I do this:

git checkout feature-branch
git rebase -i HEAD~10  # squash commits in my editor
git svn rebase  # make sure I have the latest code
git svn dcommit
git checkout master
git svn rebase # now the feature-branch squashed commit is visible on master
你对谁都笑 2024-10-30 19:52:35

您可以使用 --squash 选项来执行您想要的操作:

# rebase master and then feature-branch as above
git merge --squash feature-branch
git commit -m "Merge from feature-branch"
git svn dcommit

这可以避免使 feature-branch 成为新提交的父级。听起来多个父母混淆了 git-svn。

You may be able to do what you want by using the --squash option:

# rebase master and then feature-branch as above
git merge --squash feature-branch
git commit -m "Merge from feature-branch"
git svn dcommit

This avoids making feature-branch a parent of your new commit. It sounds like the multiple parents is confusing git-svn.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文