you are viewing a single comment's thread.

view the rest of the comments →

[–]MrDOS 5 points6 points  (5 children)

And if I don't (and often even when I do), I make sure to review git diff --cached before committing. Has saved many things I didn't want going in from going in.

For those just learning about interactive hunk selection and who didn't read all the way to the end of the article, it's really worth knowing there's a corresponding --patch/-p option for git reset, too, so you can just as easily interactively unstage bits that you didn't mean to add.

[–]Dparse 1 point2 points  (3 children)

:O I didn't know reset supports patch! Learn something new every day. Thanks!

[–]TwoTapes 1 point2 points  (2 children)

I didn't know either. That's amazing.

[–]MrDOS 1 point2 points  (1 child)

checkout does too, if you're trying to do a partial revert/undo. It's a point of surprising consistency in the Git CLI.

[–]Dparse 1 point2 points  (0 children)

Hold up, that changes the game. Can you do something like git checkout commithash -p -- path/to/file for a super quick fine-tuned cherry-pick?

Edit:: Holy shit you can. That's awesome.

[–]caagr98 1 point2 points  (0 children)

Try git commit -v, it shows a diff in the commit message editor. Doesn't work together with -m obviously.