4 ms·
Yes, that works, but it means I'm committing with a dirty work tree, so I can't really test before I commit. You're probably going to say I shouldn't test befo
by xenomachina 9y ago
Yes, that works, but it means I'm committing with a dirty work tree, so I can't really test before I commit.
You're probably going to say I shouldn't test before every commit, but I rarely work in a branch where the bar is as low as "absolutely no testing required". I generally at least want my build to pass, or some smoke tests to pass, and I can't reliably verify either of those with a dirty work tree. And actually, the fact that all of the commits on my branch are effectively going to end up in master (unless I squash) makes me want to to have even my feature branches fully tested.
- tome 9y ago> Yes, that works, but it means I'm committing with a dirty work tree, so I can't really test before I commit. Ah, I see what you want to do now. > You're probably going to say I shouldn't test before every commit If have no business telling you what you should do. If you want to test before committing, your wish is my command git stash --patch # Stash the bits you don't want to test <do your tests> git commit <options> # Commit the rest when the tests pass git stash pop <continue developing>
- xenomachina 9y agoInteresting! I guess that works because the stash doesn't contain the changes I'm going commit now, and so it doesn't conflict (at least in simple cases). I never use `--patch` (even with `git add`). I prefer to use vim-fugitive, which lets me edit a diff of the index and my working tree. It looks like being able to do something similar with stashes is a requested, but not yet implemented, feature for vim-fugitive: https://github.com/tpope/vim-fugitive/issues/236 https://github.com/tpope/vim-fugitive/issues/236
- tome 9y agoAll I can say is I use git commit --patch (and therefore `add --patch` is never even required!) git checkout --patch to selectively revert hunks, and git stash --patch to selectively stash. I couldn't be happier with this workflow!