Application 2021-06-01

How to Split a Commit in Git

Learn how to split Git commits using interactive rebase to create granular, organized commit history for cleaner code reviews.

Read in: ja
How to Split a Commit in Git

Overview

A note on the steps to split a commit.

Steps

# Specify where you want to split and rebase. Set the target commit to edit.
git rebase -i HEAD~5

# Unstage
git rebase HEAD~

# Recommit the unstaged changes at the desired granularity.
git add & git commit

# Once the commit is complete, continue the rebase
git rebase --continue

# Check the log
git log

# Force push
git push -f origin HEAD

This should allow you to split the commit.

Tags: Git
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles