How to do a rebase in Visual Studio – 114

Suppose you’ve added a new file to your solution in a branch called `experiment` for experimental purposes. You are happy with this new file and want to merge this back into master. Well, let’s say you (or someone like you*) made a change in master.

Since this is on your local machine, you can decide “do I want to have the history of the experiment branch or do I want a clean, linear timeline?” Guess which adventure you’re going to choose today 🙂

Here’s the visual setup.

experiment vs master branches histories side by side in VS

Notice how the tip of experiment has a commit that’s not in Master, and vice versa, the tip of master has a commit that’s not in experiment.

First, we’ll use Team Explorer to rebase experiment unto master. BTW I love how Team Explorer uses full sentences to confirm your intent.

rebase from the current branch experiment onto branch master

Now after the rebase, you’ll see two things:

    1. The commit from master is now shown in the experiment branch (recall the visualization from previous posts – the master pointer is now behind experimental pointer)
    2. The commit ID for “added experimental code” has changed (You can compare to the first image in this blog post to verify)

master pointer shown in experiment branch history

And lastly, let’s get master caught up to experiment by doing a merge. Yay for full sentences in the below image!

Merge from branch experiment into current branch master

And now when you refresh Master history, you’ll see the changes.

master pointer pointing to same commit as experiment

*I couldn’t resist. I listened to way too much Matchbox 20 in my youth, “I wish the real world would just stop hassling me .”

One thought on “How to do a rebase in Visual Studio – 114

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s