News for hackers. Stuff that matters.
Re:Aha Moments When Learning Git by underwater on Monday June 13, 2011 @02:32AM (#2648320)

   git add -p
That's "patch" for others who don't want to Google. Apparently can use it to choose which lines will be stored as the commit.
Re:Aha Moments When Learning Git by masklinn on Monday June 13, 2011 @05:25AM (#2648545)
> Apparently can use it to choose which lines will be stored as the commit.

The base UI is really for picking hunks (the sections you see in a `diff`), although git extended it to allow for splitting chunks into sub-hunks and ghetto-editing hunks.

Other VCS and more details:

* Darcs was probably the first VCS to implement this, it's the default behavior for `darcs record` (which is darcs's `commit` command). Much like git, darcs provides for full hunk edition (splitting hunks into sub-hunks, and removing or changing sections of hunks before recording them).

* Mercurial provides this function through the (built-in) `record` extension. It currently gives no way to split or edit hunks, only to record or ignore them. The crecord third-party extension has these features (and/but a more complex, curses-based, UI)

* `-p` is actually a subset of the much more complex `-i`/`--interactive`, which is a special staging-manipulation sub-shell.

Note however that this is a powerfully dangerous tool, as it lets you commit untested revisions (then again, so does file-selection at commit, which has been available since SVN). Revisions created this way should be tested one by one for breakage, and rewritten if needed.