Using Git add -p for fun (and profit)
techne98.com·1d·
Discuss: Hacker News
🌿git
Preview
Report Post

Here’s the problem:

You’re coding, and in flow state, and you make a lot of changes to a single file.

Now you want to commit it, but because there isn’t a single atomic change you have to suck it up and write something terrible like git commit -m "Update stuff", or commit early and often which, while good practice, can be distracting.

This is where git add -p fundamentally changed my workflow, and I feel a bit silly for not knowing about it sooner.

What git add -p actually is

The long version of this Git option is --patch, which opens up an interactive mode for staging “hunks” of text. Hunks are different pieces of code/text that Git has identified in your file.

In other words, when you do git add -p <file> it doesn’t just add the file to staging. Instead, it opens i…

Similar Posts

Loading similar posts...