Splitting / Editing an Old Commit Surviving with Git

In this episode, we will edit an old commit. More precisely, we will split a specific commit into two separate commits.

Transcript
Splitting / Editing an Old Commit

In this episode, we will edit an old commit. This means that we will, in a way, reopen an old commit - and we can then manipulate it any way we want. We can discard some changes, or add new changes, and split the original commit into as many new commits as we want.

Under the hood, Tower is using a Git tool called “interactive rebase” to make this happen. And this gives you almost unlimited flexibility.

So let’s take a look at our example scenario. And let’s say we want to edit this “Change headlines” commit here. In Tower, we can simply right-click the commit and choose “Edit” from the menu.

Tower now reopens that commit for us so that we can further edit it, including all of its changes. For our example, let’s just stage one of the changes and commit it - and then also stage and commit the rest - but in another, separate commit. Finally, we have to finish the interactive rebase session by using the “continue” button.

And voila - that’s all we have to do! Let’s look at the results!

You’ll notice that our original “Change headlines” commit isn’t here anymore - but instead, we’ve edited and replaced it with two new, separate commits. Just as we wanted to!

Editing commits in Tower provides you with a lot of power and possibilities - but in a very easy to use interface.