4 ms·
Hidden in the notes at the bottom is a pretty useful improvement to 'git stash': > 'git stash save' now accepts pathspecs. You can use this to create a stash o
by freditup 9y ago
Hidden in the notes at the bottom is a pretty useful improvement to 'git stash':
> '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!
- peff 9y agoYes, you're right. The `push` command was added because of backwards compatibility issues with `save` (and essentially replaces it).
- masklinn 9y agoWhat are the improvements of push over save? Does it allow incrementing a stash?
- peff 9y agoIt'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).
- manojlds 9y agoWas confused with the docs. Now it makes sense, the difference between save and push.
- bruce_one 9y agoOoh, 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 :-)
- mrout 9y agoTo 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.
- Watabou 9y agoDid 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 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. [1]: https://github.com/jonas/tig https://github.com/jonas/tig
- akavel 9y agoI also sometimes find :Gstatus useful when resolving merges/rebases/cherry-picks. Makes it easier and faster to iterate through the affected files.
- paulddraper 9y agoOh awesome! Much better then commit everything else, stash, then reset
- eslaught 9y agoIt'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".
- colept 9y agoPatch 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.
- ooqr 9y agoThey're definitely prereqs to upper-level git wizardry
- tgummerer 9y agoIf 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.