Sobes.tech
Senior

You branched off from develop, but develop has moved forward. How do you update your branch to the current state of develop? What is rebase?

sobes.tech AI

Answer from AI

If you have created a branch from develop, and new commits have appeared in develop, to update your branch, you can perform a rebase:

git fetch origin
git rebase origin/develop

This will move your local commits on top of the current state of the develop branch, maintaining a linear history. Rebase is an operation that "rewrites" the history of your branch by applying your changes on top of another base (in this case — the updated develop). It helps avoid unnecessary merge commits and keeps the history clean.

Important: after a rebase, if the branch has already been published, you need to push with the --force or --force-with-lease flag to overwrite the history on the remote repository.

You branched off from develop, but develop has moved… - sobes.tech