Rebase is a way of merging master to your branch when you are working with long running branch.
Step 1 − Go to your project directory and create a new branch with the name rebase-example by using the git checkout command −
The flag -b indicates new branch name.
Step 2 − Now, create a new file and add some content to that file as shown below −
The content 'Welcome to Tutorialspoint' will be added to the rebase_file.md file.
Step 3 − Add the new file to working directory and store the changes to the repository along with the message (by using the git commit command) as shown below −
The flag -m is used for adding a message on the commit.
Step 4 − Now, switch to the 'master' branch. You can fetch the remote branch(master is a branch name) by using the git checkout command −
Step 5 − Next, create an another new file, add some content to that file and commit it in the master branch.
Step 6 − Switch to the rebase-branch to have the commit of master branch.
Step 7 − Now, you can combine the commit of master branch to rebase-branch by using the git rebase command −