Mercurial: Rebasing

Occasionally, there will be incoming changes from the master repository (pull), and locally committed changes as well.

If you try to pull the incoming changes then try to push yours to the master repository, you’ll actually branch the master repository.

There’s a useful warning since this is very rarely what you actually want to do. If you do manage to force push these changes, the master repository looks like this:

Looking at the revision graph above, what we actually want to do is rebase the commits labeled “some changes”, “more changes” and “even more changes” onto the commit labeled “Incoming change from remote repository”. From eclipse, you can right-click the project, and hit Team -> Rebase:

You’ve now rebased your revisions on top of the incoming revisions, so your local repository revision graph looks like this:

Pushing this to the master repository should succeed, unless someone else has committed before you, in which case you need to rebase again.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply