How to practice a rebase on the command line – 112

In yesterday’s tip, you saw how to visualize a rebase. Today’s tip allows you to practice performing a rebase via the command line.

First, we’ll have master contain one extra commit that isn’t included in your `experiment` branch. For example, you were working on `experiment` and a new commit was added to master (either by you, e.g. bug fix, or from a remote).

master log containing a fileMaster commit

Next, you’ll have a commit on `experiment` that isn’t on master.

experiment log adding a fileExperiment not on master

Since you are on your local machine, you can rewrite history because you haven’t shared or pushed these changes.

From the `experiment` branch, you’ll run

$ git rebase master

git rebase master

and then checkout master and merge in experiment to do the fast-forward merge.

fast-forward merge

One thing the visualization is able to emphasize is how the commit IDs are different for the “added fileExperiment”.

new commit ID

The commit ID `f041b71` is no longer `1601e09` (as shown in the 2nd image for added fileExperiment).

One thought on “How to practice a rebase on the command line – 112

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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