A helm interface for git hunks - browsing, staging, unstaging and killing.
It's on MELPA, so run M-x package-install helm-hunks
to install it.
Or preferably using the ingenious use-package declaration
(use-package helm-hunks
:commands (helm-hunks
helm-hunks-current-buffer
helm-hunks-staged
helm-hunks-staged-current-buffer))
Along with helm-follow-mode, this plugin will let you jump around and stage git hunks like never before!
Run M-x helm-hunks
, turn on helm-follow-mode
with C-c C-f
, and jump around using C-n
and C-p
. Run helm-hunks-current-buffer
to jump around the current buffer only.
Hit C-c C-p
inside helm-hunks to show diff previews in-line with the hunks. For even faster navigation, narrow the selection by typing in the helm buffer, like in any other helm plugin - this even works for parts of the actual diff!
To have it always open with previews enabled, use
(setq helm-hunks-preview-diffs t)
For hunks you're ready to commit, hit C-s
to stage the hunk directly from the helm-hunks buffer.
Use C-c C-o
and C-c o
to open hunks in "other frame" and "other window", respectively.
To browse already staged hunks, run helm-hunks-staged
or helm-hunks-staged-current-buffer
, and use C-u
to unstage/reset a hunk.
Use C-k
to kill hunks gone bad.
Add a hook to helm-hunks-refresh-hook
to refresh your favorite git gutter when hunks are staged. A hook for git-gutter+
is already in place.
(add-hook 'helm-hunks-refresh-hook 'git-gutter+-refresh)
Use C-c C-c
to pop open a commit dialog or amend to the previous with C-c C-a
.
C-c C-k
quits.
PRs welcome!
- Kill hunks
- Allow resetting staged hunks
- Show staged hunks
git-gutter+ - https://github.com/nonsequitur/git-gutter-plus
helm-ag - https://github.com/syohex/emacs-helm-ag
Copyright (C) 2016 Torgeir Thoresen
Author: @torgeir
Keywords: helm git hunks vc
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.