Stage Specific Lines Using Git Add Patch (Edit)
I use git add -p all the time to stage parts of a file but sometimes you need fine grain control over staging lines, edit handles that.
A while back I wrote about using git add patch which lets you pick through hunks of changes in a file to stage instead of a whole file. This works great most of the time but sometimes you can’t split a hunk to include the exact lines you want to stage.
This post will take things 1 step further and go over how to stage specific
lines using the e
(edit) feature of git add patch. This lets you pick and
choose which lines get staged using your code editor of choice.
# Demo Video
# Timestamps
- 0:25 – Quick demo of when splitting hunks fails
- 1:15 – Using git add patch edit
How often do you use this method to stage commits? Let me know below.