Starting from branch master, to merge a topic branch one just says
git merge topic
If one wants to rebase, however, the commands are
git rebase master topic
git checkout master
git merge topic
The last two lines just fast-forward the master branch to the topic branch, so variation is possible, e.g. I like the following pattern:
git rebase master topic
git rebase topic master
It gets even more complex when the state of the local “topic” branch shall be preserved:
git checkout -b tmp topic
git rebase master
git rebase tmp master
git branch -d tmp
Is there a simple command for that? Something that works as simple as git-merge on the CLI but actually performs a rebase, without moving the topic branch?
There’s no perfect command that does this in one go, but there’s a pretty close second.
Assuming that
topicwill cleanly fit atopmasterwithout conflict, this will work from themasterbranch:master..topicis the set of changes intopicbut notmaster, and cherry-picking them in order is effectively a rebase iftopicis cleanly onmaster.For the two-command perfect-fidelity case (or three to preserve
topic), I wouldn’t do tworebases like you have there, I would do arebaseand anupdate-reffor clarity.