From 1aed46c072fd9bd00650474e89f0e4d3a483dad8 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Thu, 26 Nov 2015 09:47:06 +0000 Subject: [PATCH] Add a note about unstaging staged changes. --- README.mkd | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.mkd b/README.mkd index 4a4a1a8..cf37cdd 100644 --- a/README.mkd +++ b/README.mkd @@ -110,6 +110,8 @@ You can stage or revert an individual hunk when your cursor is in it: * stage the hunk with `hs` or * revert it with `hr`. +See the FAQ if you want to unstage staged changes. + The `.` command will work with both these if you install [repeat.vim](https://github.com/tpope/vim-repeat). To set your own mappings for these, for example if you prefer the mnemonics hunk-add and hunk-undo: @@ -281,6 +283,24 @@ Add `let g:gitgutter_highlight_lines = 1` to your `~/.vimrc`. ### FAQ +> Why can't I unstage staged changes? + +Unstaging staged hunks is feasible but not quite as easy as it sounds. There are three relevant versions of a file at any one time: + +1. The version at HEAD in the repo. +2. The version staged in the index. +3. The version in the working tree, in your vim buffer. + +`git-diff` without arguments shows you how 3 and 2 differ; this is what vim-gitgutter shows too. + +`git-diff --staged` shows you how 2 and 1 differ. + +Let's say your are looking at a file in vim which has some unstaged changes. Now you stage a hunk, either via vim-gitgutter or another means. The hunk is no longer marked in vim-gitgutter because it is the same in 3 and 2. + +Now you want to unstage that hunk. To see it, you need the difference between 2 and 1. For vim-gitgutter to shows those differences, it would need to show you 2 instead of 3 in your vim buffer. But 2 is virtual so vim-gitgutter would need to handle it without touching 3. + +I intend to implement this but I can't commit to any deadline. + > Why are the colours in the sign column weird? Your colorscheme is configuring the `SignColumn` highlight group weirdly. Please see the section above on customising the sign column.