GIT Cherry选择我在一个分支中存在的所有提交到另一个分支
问题描述:
我有两个分支A和B.分支B有时是从分支A分支出来的,并且多个用户正在向这两个分支提交.我想从分支B到分支A挑选我所有的提交(分支A中尚不存在),而无需手动搜索每个提交. 有可能吗?
I have 2 branches A and B. Branch B was branched from branch A at some time and multiple users are committing to both branches. I want to cherry pick all my commits (that doesn't already exist in branch A) from branch B to branch A without the need to manually search for every single one. Is it somehow possible?
谢谢
答
更直接的方法是使用 rebase --onto :
git rebase --onto target-branch [LAST_COMMON_COMMIT_BEFORE_BRANCH] branch-to-move
如果您的仓库看起来像这样:
if your repo looks like this:
a - B - c - d - e -> master
\ \
\ f - g -> some-feature
\
h - i - j -> branch-to-move
命令
git rebase --onto some-feature B branch-to-move
将导致
a - B - c - d - e -> master
\
f - g -> some-feature
\
h' - i' - j' -> branch-to-move