Syndication Icon
Published May 10, 2020 Updated May 10, 2020

Git Rebase Break

  • Duration

    02:15

  • Operating System

    macOS

  • Shell

    bash

  • Terminal

    xterm

Transcript

# Hello and welcome to the Alchemists Screencasts!
# Today, we'll look at Git Rebase Break.

# The ability to *break* in the middle of a rebase was added in Git 2.20.0.
# I think of *break* as a exploratory/debugging tool.
# For instance, here's the history of our documentation feature branch:

gl documentation...master

# 💡 See the *Git Log Pretty* screencast to learn more about the `gl` alias.
# Let's put a *break* after the first commit by using interactive rebase:

git rebase --interactive

# Notice Git Rebase stopped after the first commit.
# Adding "b" (i.e. "break") after the first commit made this possible.
# To confirm, here are the details:

git show

# Notice there is no body to the commit.
# That was careless of us so we might as well correct this behavior:

git commit --amend

git show

# There, much better.
# Granted, we could have used Git Rebase Edit for this.
# 💡 See the *Git Rebase Edit* screencast for details.
# In this case, we were exploring and saw a chance to improve documentation.

# Before continuing with the rebase, let's say we forgot to add a license:

vi LICENSE.adoc

git add LICENSE.adoc
git commit

# This technique is similar to the *Git Rebase Pick* screencast.
# Except, in this case, we *added* rather than pick an existing commit.

# At this point we could run tests, check the state of the project, etc.
# There is a lot you can do when breaking in the middle of your history.
# For the purposes of this tutorial, we'll continue with the rebase:

git rebase --continue

# With the rebase complete, let's check our history one last time:

gl documentation...master

# The only visible change is the addition of the license commit.
# With Git Rebase Break, we were able to:
#  1. Inspect and edit the commit before the break.
#  2. Add a new commit.
#  3. Potentially run tests, etc. at the point in time of the break.
# Break is another tool in your Git Rebase Workflow. 🎉

# Enjoy!
# https://www.alchemists.io
# ☿ 🜔 🜍 🜂 🜃 🜁 🜄