I am calling for better git GUI client change staging support!

All git clients are line-oriented, i.e. the granularity of change is one line. Wouldn’t be great if there was a feature to commit an arbitrary change within a line?

Consider the following example:

We have all been there:

I have been working on a large factoring. I am done refactoring the code and now it is time to commit the changes. However, I don’t want to commit the entire thing at once – I am going to commit changes in logical groups. That involves reading the entire diff and “cherry” picking the lines that belong to the change that I want to describe.

However, sometimes a single line includes multiple changes that need to be committed separately. In the above example, there are 3 distinct changes:

  1. configuration parameter has been added as the first parameter of plugin function.
  2. adManager has been replaced with slotManager .
  3. plugin type has changed from TaggingPluginInterface type to PluginFactoryType .

However, all of these changes belong to separate commits:

feat: extend TaggingPluginInterfaceType with configuration param
refactor: replace AdManager with SlotManager
refactor: replace TaggingPluginInterface with PluginFactoryType

To make all of these commits, I first have to revert the line to what it was originally. Then add the first change (add configuration parameter):

Commit the change.

Then change adManager to slotManager :

Commit the change.

Then change TaggingPluginInterface to PluginFactoryType :

Commit the change.

Thats a lot of going back-and-forth just to commit a single line!

However, a smart git GUI client could perform all of the above behind the scenes.

To do this, first you need to find word level changes between two lines. A brilliant file comparison tool Kaleidoscope can already to this:

Then ask user to select part of a line in the “removed” line and part of a line in the “added” line:

Using the two selections, stage a line that has the first selection removed and the second added. For multiple per line that need to be committed, allow to iterate the process multiple times.

Unfortunately, without this feature, the task of separating multiple changes on a single line into different commits is exceedingly laborious. As a result, it is not uncommon to see commits that mix changes that should be in separate commits.

However, you can change this. Markets respond to demand. Raise an issue with your favourite git GUI client describing the feature request.

Know a tool that already supports this? I’d love to know which one.

Tech / Product Founder — building https://contra.com/

Tech / Product Founder — building https://contra.com/