git add -e file.txt

Category: Git - Core

git add -e file.txt

Edit the staged patch in your editor

Stages the file but opens the generated patch in your editor first, letting you hand-edit hunks before they enter the index. It is a surgical alternative to git add -p when you know exactly what belongs in the commit. Save and close the editor to apply the edited patch.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.