我在我的git仓库中有一个develop分支和一个feature分支。我向develop分支添加了一个提交,现在我希望将该提交合并到我的feature分支中。如果我这样做:
git checkout feature
git merge develop
我最终会得到一个合并提交。由于我经常将develop分支上的新提交合并到我的特性分支中,所以我想避免所有这些不必要的合并提交。我看到了这个答案建议执行git rebase develop
,但它会将我的分支回溯得太远,导致重置失败。
更新: 我最终采取的方法是
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
更新:我刚刚注意到,在将开发分支合并并变基到功能分支时,原始提交会获得不同的哈希值。我认为这不是我想要的,因为最终我会将功能分支合并回开发分支,我猜这样做可能会出现问题。