The letter A styled as Alchemists logo. lchemists
Published June 15, 2025 Updated June 15, 2025
Cover
Git Rebase Break

The break command was added in Git 2.20.0 and is similar in nature to Git Rebase Edit but doesn’t target a specific commit. Instead, break works more like a breakpoint when debugging code. When rebasing, this means Git will halt the rebase wherever you place the break. You’re not limited to a single break either and can add as many as makes sense when rebasing your code.

Let’s explore how this simple command can be quite powerful when rebasing.

Workflow

To start, we’ll create a Git repository for demonstration purposes:

mkdir demo
cd demo
git init

Now we can add a few commits and, to keep this simple, we’ll use empty files to populate the repository. In this case, the content of the files doesn’t matter as much since we are more concerned about their order in the history. Here’s the commits to create:

# README
touch README.adoc
git add .
git commit --all --message "Added project documentation"

touch VERSIONS.adoc
git add .
git commit --all --message "Added project versions documentation"

touch CODE_OF_CONDUCT.adoc
git add .
git commit --all --message "Added code of conduct guidelines"

touch CONTRIBUTING.adoc
git add .
git commit --all --message "Added contribution guidelines"

If you run git log --oneline, you should see a Git history similar to the following:

0c7d5a729c11 (HEAD -> main) Added contribution guidelines
00f20ce079c9 Added code of conduct guidelines
5900b32b6009 Added project versions documentation
11cfe4ca4eea Added project documentation

Now we can perform an interactive rebase (this assumes you have Git Rebase Abbreviations enabled):

git rebase --interactive --root

⚠️ Please note that we’ll be rebasing our main (default) branch. In practice, Git Rebase should only be performed on a feature branch but since this repository isn’t shared with anyone, we can freely rebase without harming anyone.

You should now see the following in your Git Rebase Editor:

p 11cfe4ca4eea Added project documentation
p 5900b32b6009 Added project versions documentation
p 00f20ce079c9 Added code of conduct guidelines
p 0c7d5a729c11 Added contribution guidelines

To add a break, add b after the first line. Like this:

p 11cfe4ca4eea Added project documentation
p 5900b32b6009 Added project versions documentation
b
p 00f20ce079c9 Added code of conduct guidelines
p 0c7d5a729c11 Added contribution guidelines

Now you can save an exit to perform the rebase. You’ll notice that the rebase halted after the second commit where you placed the b. To confirm, use git show to output something similar to the following:

commit 11cfe4ca4eeaf72f364eb53977776ffc31fcf69d (HEAD)
Author: Brooke Kuhlmann

    Added project versions documentation

added: VERSIONS.adoc

At this point, there is a lot you can do when halted such as:

  1. Inspect and/or use your application with only the changes applied at this point in your commit history.

  2. Run the test suite.

  3. Add more commits.

  4. Amend the last commit.

In this case, we’ll amend the last commit by adding a body. Yes, this is similar to using Git Rebase Edit but want to show that you can also use break in this capacity as well. To amend, run:

git commit --amend

Next add the following body to your commit message:

Details the chronological history of the project by release date. The project history is critical in conveying the evolution, changes, feature set, and reasons why one would want to upgrade.

Now you can save, exit, and run git show to confirm your changes. You’ll see the newly added commit body in the output. Before continuing our rebase, let’s pretend we forgot to add a license to our project. We can do this by adding a license file and committing the changes as follows:

touch LICENSE.adoc
git add .
git commit --message "Added license"

ℹ️ Normally, you’d add content for the license file and provide a commit message with a subject and body to explain why this change is important — as is proper Git Commit Anatomy — but, for now, this demonstration is only focused on showing how to add additional commits during a break in the Git Rebase.

Finally, we can wrap up our rebase by continuing and looking at our history as follows:

git rebase --continue
git log --oneline

The above will yield the following:

6964bbdb766b (HEAD -> main) Added contribution guidelines
9918ec640e49 Added code of conduct guidelines
04e97c7e05f2 Added license
5900b32b6009 Added project versions documentation
11cfe4ca4eea Added project documentation

The only visible change is the addition of the license commit but you can always run git show <sha> to view the "Added project versions documentation" commit message to see our amended changes.

Conclusion

The break command is a simple but useful command to have in your Git Rebase workflow for all the reasons shown and mentioned earlier. You can also use the command to halt a rebase, without making any changes, to debug your code at a particular point in history and then continue after your done.

May your rebases be quick to inspect and/or debug. Enjoy!