Regular rebase before submitting merge request(pull request)

david medragh
2 min readJan 21, 2022

With a regular rebase we can update our feature branch with the default branch (or any other branch). This is an important step for Git-based development strategies. we can ensure that the changes we’re adding to the codebase do not break any existing changes added to the target branch after we created our feature branch.

When we rebase:

  1. Git imports all the commits submitted to main after the moment we created our feature branch until the present moment.
  2. Git puts the commits we have in our feature branch on top of all the commits imported from main:

To update my branch my-feature-branch with our default branch (here, using develop):

1-fetch the changes of your origin branch

git fetch origin main

2-we should be on the the branch to which you want to rebase

git checkout my-feature-branch

3-Then we can start rebasing

git rebase origin/main

4-Here is the time to fix the conflict when same files are changed locally and on the remote branch and decide what to do and at the end add them git add

git add .

5-We then continue when asked for

git rebase --continue

6-Finaly we must update our remote branch by

git push --force-with-lease

--

--