GIT Demystifying part 14
rebase
Create the tree.
A failed try of rebase, then do a rebase --abort.
The correct way of do the Rebase.
Create the tree.
With rebase git allow us to rearrange the tree in order to simplify two branches into one, moving one of then to the end to the other, basically.
Let´s create a Y tree.
Opps, the commit name must be c2, lets change the name. use command:
git commit --amend
Continue creating the tree
Finishing the tree, the tree has two branches, master and branch_01, and master has one or more commits after the common node. At this point we can merge the two branches, and this operation will be registered as a join between the two branches. With rebase the branch_01 will be moved to the end node (c5) of the other branch (master), mergin the files, and registering only one branch (master), resulting in a simple and simplified look of the tree.
A failed try of rebase, then do a rebase --abort.
First lets do a failed rebase and learn from this situation. the correct steps to do the rebase are:
- over the branch_01 apply git rebase master.
- solve the conflicts if apply.
- git rebase --continue. At this point the branches are unified in only one, but master pointer are not on the end of the branch.
- change to master branch.
- git rebase branch_01. this will rewind head to the top of the now only one branch.
With this intention we do some errors, and at the end abort the rebase.
trying to commit corrected conflict over two branches. (totally wrong way, never need the commit, instead git rebase --continue).
continue
The correct way of do the Rebase
Let´s check if the states is the correct.
Follow this steps.
- over the branch_01 apply git rebase master.
- solve the conflicts if apply.
- git rebase --continue. At this point the branches are unified in only one, but master pointer are not on the end of the branch.
- change to master branch.
- git rebase branch_01. this will rewind head to the top of the now only one branch.
eot
No hay comentarios:
Publicar un comentario