GIT Cherry选择我在一个分支中存在的所有提交到另一个分支 [英] GIT cherry pick all my commits that exists in one branch to another branch
本文介绍了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
这篇关于GIT Cherry选择我在一个分支中存在的所有提交到另一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文