Rebase Branch – Git Rebase

Applying Changes with Git Rebase

git rebase is the command used to reapply all the commits made on the topic branch on top of the HEAD of the base branch (the branch that the topic branch was separated from). This command is useful when you want to streamline commits made on multiple branches. The rebase operation can also be done through a Remote Repository on the GitHub platform. It is an option of the merge feature of GitHub.

In the command line, you need to run the command on the branch to be rebased (a divergent branch) and specify its base branch name as a command parameter.

git rebase [base branch name]

The rebase command changes the divergence point to the HEAD of the base branch. It doesn't impact the base branch itself. If you want to integrate the changes into the base branch (e.g., the master branch), you need to run the git merge command on the base branch side. The merge action will be the Fast-Forward merge as the divergent branch is already ahead of the HEAD of the base branch.

For a better understanding, please go through the following practice section.

Practice

bloovee-round-icon.pngDeveloper A (Project Owner Role)

Objective:
Learn how to rebase a branch

1. Prepare a practice file

In the practice on the previous page, we merged Branch_A with the master branch using the squash option. F