Git Rebase

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.

Links to this page
  • Git Pull

    By default, pull is just a shorthand of 202204261123# after #202205251612 from remote repository. Add option --rebase to use 202204261122# instead.

  • Git Merge

    It is useful for feature development and bug fixes especially if these are split from a branch. It is similar to 202204261122 but the latter focus on having a linear commit history instead of preserving split and merge points.

  • Git Cherry-Pick

    cherry-pick {commits...} is a powerful tool for introducing individual commit(s) to the current branch without incorporating branches like 202204261122 and 202204261123. The commits will be attached to the HEAD of the current branch in ascending order.

  • Git
#vcs #git