How to "reinstall" one commit?

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 it gives rise to conflicts. But the situation is simpler: I would like to put a single topiccommit on master.

git checkout master
git cherry-pick topic
git checkout topic
git reset --hard master
git checkout master
git reset --hard HEAD~1

Is it impossible to make teams with one team higher?

+4
source share
1 answer

Reset your branch first, then use the reflog to find a commit for the 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 - is to pass a rebase range of commits, which consists of only one commit, which you want to reset:

git rebase --onto master topic^ topic
+2
source

All Articles