Rebasing
Rebasing is nothing more than taking one branch and adding it to the tip of another, where the tip is simply the last commit in the branch. For example, suppose you have the following structure:
Figure 5.1: Git structure
You can't do a fast forward here, because Main has moved on since you branched from it. You can do a true merge, but a true merge adds a commit to your history every time you do one:
Figure 5.2: True merges
A rebase solves the same problem, but without adding merges to the commit history.
Notice that as you review this history, you have to skip over a significant number of commits since they are just merges. Rebase eliminates most of these commits.
Here comes the important part:
- You merge branch Feature1 into Main, but you rebase Feature1 onto Main.
- Returning to our earlier example, if you rebase Feature1 onto Main, it looks like this:
Figure 5.3: After the rebase
- There is...