back

by JNRowe·2y ago·view on hn ↗
`git add -p` can also work for new files, it just requires you to call `git add --intent-to-add` first. After using -N/--intent-to-add you'll see that the file is registered in the status output, and -p will work exactly how like you expect.

I often find myself spiking things then breaking them back down with -N and repeated `git commit -p` to form a reasonable history. The workflow seems to really suit my mind. However, it does require some testing vigilance if you're manually editing the hunks for clarity on top of simply splitting them up.

1 comments
Thanks for the hint about `--intent-to-add` / `-N`.

There's constantly new things to learn about git. I use `git add -p` extensively, but never thought to check for an option like that.