As a follow-up to the previous post, let me mention another Git trick. I often stage files in chunks (or even line by line), using Magit’s equivalent of git add --patch
. It is not obvious, however, what to do if I want to stage some part of a file which is not yet tracked by Git – if I just git add
it, it is staged as a whole.
It turns out, however, that there is a way – this is Git, after all. If you say git add -N some-file
, Git stages some-file
as an empty file, and you can git add --patch
parts of it.
You’re welcome.