Hacker News new | past | comments | ask | show | jobs | submit login

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




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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: