DEV Community

Rex
Rex

Posted on

One thing to do before Git Rebase to other branch

When rebasing, Git will iterate each commits since the divergence.

If there is a conflict in a commit, it stops and wait for the conflict to be resolved. After resolving the conflict, we can “Git rebase —continue” to resume the process.

It can be confusing to see stale changes and resolving conflict with stale changes again and again is not fun.

The one thing to do before rebasing to other branch is: squash or fix up commits into one commit so that when you resolve conflict, it is against the latest changes and you only have to do it once.

To squash the commits: “Git rebase -i HEAD~5”, replace the number 5 to the number of commits you intend to squash.

Top comments (0)