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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help