History is written by the victors…

Nick Lydon
Nov 16, 2022

… and is rewritten by developers using git!

Aqua Mechanical

If you want to keep your git history clean you probably use rebase to squash commits, rename commit messages or reorder commits to make it appear more logical.

When changing history though, it’s possible to introduce bugs at various commits. For example, moving a commit where a method is called further back in time prior to when that method was actually created! This would cause the code at that particular commit to fail at compilation.

To get around this you can use the --exec command whilst rebasing. It allows you to pass a command that will verify your changes are correct at each step, e.g. --exec 'dotnet test' which will ensure the solution builds and tests pass all throughout the git history.

--

--

Nick Lydon

British software developer working as a freelancer in Berlin. Mainly dotnet, but happy to try new things! https://github.com/NickLydon