I\'m using git and want to change the base of an exiting branch. This is caused by a deployment system, which pulls this explicit branch into my production environment. When pla
yes, you can use rebase to achieve the desired effect. the following command will checkout the deploy
branch and replay all its commits, which are not reachable through v1.1
, on top of v1.1
:
git rebase v1.1 deploy
(the verbose way would be: git rebase --onto v1.1 v1.0 deploy
)
but why rebasing and altering history? you can simply change the mainline of development into your deployment-branch:
git checkout deploy
git merge v1.1
this will leave all your commit hashes intact, your history will then look like this (M
being the merge commit):
C---D---E-----------M deploy
/ /
A---B---F---G---H---I---J---K master
\ \
v1.0 v1.1
since conflicts might arise during rebase as well as during merge, you will have a history of merge conflicts when using the merge based approach. with rebase you don't have a history of conflicts which happened during rebase operation. using a merge based workflow, you can later see your conflicts in the (combined) diff of the merge commits.