Search⌘ K

Walkthrough of a Simple Rebase

Explore a step-by-step Git rebase walkthrough that guides you through initializing a repository, creating branches, resolving conflicts, and merging with fast-forward. Understand how rebasing reshapes commit history and supports effective branch management to prepare you for real-world version control tasks.

Rebase scenario

Let’s walk through the scenario from the previous lesson with Git commands.

1	mkdir lgthw_rebase
2	cd lgthw_rebase
3	git init
4	echo A > file1
5	git add file1
6	git commit -am A
7	echo B >> file1
8	git commit -am B
9	echo C >> file1
10	git commit -am C
11	git checkout -b feature1
Terminal 1
Terminal
Loading...

The -b flag

This is a shortcut that creates the branch and checks it out all at once. Using this means you don’t get into the situation where you can create a branch but forget to explicitly check it out before ...