【发布时间】:2013-07-25 10:59:34
【问题描述】:
我的 git 存储库中有一个开发分支和一个特性分支。我添加了一个开发提交,现在我希望将该提交合并到我的功能分支。如果我这样做
git checkout feature
git merge develop
我最终得到了一个合并提交。由于我会经常将开发中的新提交合并到我的功能分支中,因此我想避免所有这些不必要的合并提交。我看到这个answer 建议做一个git rebase develop,但它最终将我的分支倒带得太远并且rebase 失败了。
更新: 我最终做的是
git checkout feature
git merge develop # this creates a merge commit that I don't want
git rebase # this gets rid of the merge commit but keeps the commits from develop that I do want
git push
更新:我刚刚注意到,当我合并然后 rebase 到功能分支时,develop 上的原始提交会获得不同的哈希值。我认为这不是我想要的,因为最终我会将功能重新合并到开发中,我猜这不会很好玩。
【问题讨论】:
-
嗯,我知道当你变基时你可以将你的提交“压缩”在一起,作为一种在你的分支上没有太多提交的方法。查看gitready.com/advanced/2009/02/10/…。
-
变基是的答案,如果它不适合你,还有另一个问题你应该问为什么它不工作。
标签: git git-merge git-rebase feature-branch