How to rebase commits to another branch (Git)

we are going to perform a very simple rebase, where we will introduce a new file, commit that file, make a change to it, and then commit it again so that we end up with two new commits.

Step 1 : The jgit repository can be cloned as follows

Step 2 : Check out a new branch, rebaseExample, which tracks origin/stable-3.1:

Step 3 : Make two commits on the rebaseExample branch, as follows:

Step 4 : Then, we rebase the change on top of the origin/stable-3.2 branch instead:

Step 5 : When you execute git rebase, Git starts by finding the common ancestor of the current HEAD branch and the branch you want to rebase to. When Git finds merge-base, it will find the commits that are not available in the branch you are rebasing onto. Git will simply try to apply those commits one by one.