t's simple. With rebase you say to use another branch as the new base for your work.
If you have, for example, a branch master, you create a branch to implement a new feature, and say you name it cool-feature, of course the master branch is the base for your new feature.
Now at a certain point you want to add the new feature you implemented in the master branch. You could just switch to master and merge the cool-feature branch:
$ git checkout master
$ git merge cool-feature
But this way a new dummy commit is added. If you want to avoid spaghetti-history you can rebase:
$ git checkout cool-feature
$ git rebase master
And then merge it in master:
$ git checkout master
$ git merge cool-feature
This time, since the topic branch has the same commits of master plus the commits with the new feature, the merge will be just a fast-forward.
a rebase is quite often a good idea to do before a merge, because the idea is that you integrate in your branch
Ythe work of the branchBupon which you will merge.
But again, before merging, you resolve any conflict in your branch (i.e.: "rebase", as in "replay my work in my branch starting from a recent point from the branchB).
If done correctly, the subsequent merge from your branch to branchBcan be fast-forward.a merge directly impacts the destination branch
B, which means the merges better be trivial, otherwise that branchBcan be long to get back to a stable state (time for you solve all the conflicts)
No comments:
Post a Comment