Consider the following tree:
A --- B --- C --- D --- E --- F --- master
\
\
B' --- C' --- D' --- topic
where (B != B')
. I would like to do git rebase --onto master master topic
but this generates conflicts. But the situation is simpler: I would like to put the single topic
commit onto master.
git checkout master
git cherry-pick topic
git checkout topic
git reset --hard master
git checkout master
git reset --hard HEAD~1
Isn't it possible to do with a single command the commands above?
Reset your branch first, then use the reflog to find the commit to cherry pick:
git checkout -B topic master # re-create topic branch at the commit of master
git cherry-pick topic@{1} # copy the old tip of the topic branch
Another – maybe even simpler – way would be to pass rebase a range of commits which only consists of the single commit you want to have rebased:
git rebase --onto master topic^ topic
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.