News for hackers. Stuff that matters.
Re:Git Undo by derefr on Thursday August 25, 2016 @06:32AM (#12357991)
Most git command-lines are lengthy enough to give me time to consider them, so I don't often feel the need to "take back" a git invocation. What I do often screw up, though, is the (almost hypnotic) tapping of y/n when doing a `git {add, reset, checkout} -p` to prepare and clean up a commit.

Ideally, with all of the -p commands, git wouldn't actually apply any of the changes I specified until it was about to quit (i.e. either when I advance past the end of the set of potentially-affected hunks, or I manually type 'q'), and then would prompt me for whether {set of operations I specified} is what I wanted to do. This would leave the -p operations the the flexibility to expose an 'u'ndo.

Re:Git Undo by arghimonmobile on Thursday August 25, 2016 @06:59AM (#12358092)
You'd probably really like Magit mode for Emacs then. What you're describing with interactive add becomes trivial since you can stage parts of the diff by selecting them in a region. I can hardly live without Magit these days. Bonus is that it even works on remote hosts via tramp. </emacs plug>
Re:Git Undo by roblabla on Thursday August 25, 2016 @07:18AM (#12358156)
<vim plug>With the vim-gitgutter plugin installed, you can dynamically add/remove/undo hunks without even leaving the editor[0]. I use this instead of `git add -p` nowadays</vim plug>

[0]: https://github.com/airblade/vim-gitgutter#getting-started

Re:Git Undo by hacker42 on Thursday August 25, 2016 @07:27AM (#12358199)
<spacemacs plug />
Re:Git Undo by throwanem on Thursday August 25, 2016 @07:28AM (#12358201)
I can enthusiastically second this recommendation. If you use Emacs and Git, but have not yet tried Magit, you are missing out.
Re:Git Undo by Tyr42 on Thursday August 25, 2016 @08:27AM (#12358463)
As long as its not the last one, you can go back with `K` to the previous hunk. And forward with `J`. (The lowercase versions only go to hunks you decided to skip, but uppercase go to all, even ones you already chose an option for)