Rewording commits

Suppose that we realize that we made a spelling mistake in the commit message of a commit previous to the last one, but that we haven't yet pushed onto a remote repository. We can change the wording with interactive rebasing.


As an example, suppose we want to reword commits 6fb2ba7 and fe1a154. To start interactive rebasing at the parent of oldest commit we run

git rebase -i 6fb2ba7^
Rewording commits 1

Now, in GitLens we select the reword option for both commits. We save and close the file to start the rebasing process.

Rewording commits 2
Rewording commits 3

When we close, Git starts the rebasing process. Every time it reaches a commit that we want to reword it opens VS Code so that we can enter our new message. Once we do, we save, close, and Git continues the rebasing process until all commits have been rebased.

If we check our log now we will see that the commits that we selected have been reworded. Notice too that since Git generated new commits, their IDs are not the same as before the rebase.

Rewording commits 4