Git Rebase

The easiest way to integrate branches in Git is the merge command.

However, there is another way: you can take the patch of the change that was introduced in a commit and reapply it on top of a specific point.

In Git, the rebase command allows you to take all the changes that were committed on one branch and replay them on another one.

As an example, you’d run the following:

$ git checkout currentBranch
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: commit done in currentBranch

There is no difference in the end product of the integration, but rebasing makes for a cleaner history. If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel.

Check the appropriate section in the Git-Scm ebook for more infos.

Also, the following 2 videos explains a great ton of things regarding the Rebase command.

And this one

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s