3 ms·
Git's stash and clean commands make it possible to test partial commits built up in the staging area pretty easily. There's even a section of the man page for s
by spacemanaki 15y ago
Git's stash and clean commands make it possible to test partial commits built up in the staging area pretty easily. There's even a section of the man page for stash that's titled "Testing partial commits". I think this is essentially the flow described there:
emacs foo.c # make two changes
git add --patch foo.c # stage only one change
git stash save --keep-index # stash changes not yet staged
git clean -f # delete untracked files, like build artifacts
# now the files on disk are in the same state as what you are about to commit
Sure, it's more complicated than just not having a staging area, but it can be really useful, and it's really cumbersome to manually tease apart changes in the same file.
- prodigal_erik 15y agoThanks, I had missed that. It's almost as handy as the --patch option "git stash" didn't have.