rebase {target}
incorporates branches by manipulating the history of commits. The result of it will be a linear and clean commits without divergences. All commits of the current branch, if they do not contain duplicated commits in the target branch, will be attached to the HEAD of the target branch.
These newly attached commits are the clone of the original commits which are discarded like in Git Reset. However, you can still see them in Git Reflog.
Note: rebase {target} {source}
will automatically check out to the source branch first before rebase it to the target branch. It is a shorthand of checkout {source}
follow by rebase {target}
.
It is useful for feature development and bug fixes especially if these are split from a branch. Note the similarity to 202204261123 but the latter focus on preserving the merge history rather than having a clean commit history.
When using the interactive mode, -i
, rebase
could arbitrarily choose which commits should be applied and what order should they be in. This is suitable for history rearrangement. It shares some similarity with 202204261212. However, the latter does not incorporate branches.