It's worth noting that "git stash -p" (aka "git stash --patch") already exists and allows you to commit individual files or hunks within a file. Though the cost is going through an interactive interface, so some users might prefer the new "git stash push". Still, if you can't upgrade, use "git stash -p".
Patch and interactive modes are the best thing next to sliced bread. I'll start with a feature and end up refactoring something and it's difficult to organize large sets of changes without them.
They're definitely prereqs to upper-level git wizardry
If you can upgrade you can use "git stash -p" with pathspecs as well, so you can stash some changes in a specific file without having to go through changes in other files.
Ooh, this might mean some vim-fugitive beauty is on the horizon :-)
The vim-fugitive Gdiff is a really nice interface (imo) and a stash equivalent would be amazing :-)
To me the most useful parts of fugitive, the only things that actually feel more useful than the command line equivalents, are fugitive-:Gdiff and fugitive-:Gblame.
:Gblame is particularly useful.
Did you try tig [1]? I prefer the command line solution to shoving complicated things and UI (which fugitive is -- I could barely remmeber all the features I had and like you, I only really ever used the :Gblame command the most) into vim. I prefer to have vim be lightweight and let other tools do their job (i.e the UNIX way).
I don't use fugitive now but I do make full use of tig. In my .vimrc I have:
nnoremap <leader>gb :echo system("git rev-parse --abbrev-ref @ <bar> tr -d '\n'")<CR>
nnoremap <leader>go :silent !tig<CR>:silent redraw!<CR>
nnoremap <leader>gB :silent !tig blame % +<C-r>=expand(line('.'))<CR><CR>:silent redraw!<CR>
The above solution leaves vim purely for editing, and tig for doing the actual git presentation.Asciinema demo of tig blame: https://asciinema.org/a/4as7ujt8cpnpyx0doyrervatl
Just like fugitive, I can travel back and forth through history. And if I hit q, I'm back in vim.
I also sometimes find :Gstatus useful when resolving merges/rebases/cherry-picks. Makes it easier and faster to iterate through the affected files.
Yes, you're right. The `push` command was added because of backwards compatibility issues with `save` (and essentially replaces it).
What are the improvements of push over save? Does it allow incrementing a stash?
It's essentially the same except for the arguments. `save` took the whole command-line to be the stash message, which was confusingly unlike the rest of Git (and needed to be addressed before pathspec support could be added).
Was confused with the docs. Now it makes sense, the difference between save and push.
Re:Git 2.13
by paulddraper on Tuesday May 09, 2017 @11:05PM
(#14305632)
Oh awesome! Much better then commit everything else, stash, then reset
> 'git stash save' now accepts pathspecs. You can use this to create a stash of part of your working tree, which is handy when picking apart changes to turn into clean commits.
I believe there may be a slight error in the GitHub blog post I quoted above: from what I can tell, it's actually the 'git stash push' command that now accepts pathspecs. But either way, still a neat new feature!