4 ms·
Why stash? Why not just branch then commit?
by ben174 10y ago
Why stash? Why not just branch then commit?
- Grue3 10y agoBecause you might be currently not at the place where you intended to branch off. For example trying to make a bugfix on an experimental feature branch, but then you realize you should branch it off master.
- geofft 10y agoSo branch to a temporary branch, commit, checkout the branch you wanted to be on, cherry-pick the temporary branch to grab its head commit, then delete the temporary branch once you're sure you don't need it. This isn't completely safe because deleting a branch also deletes its reflogs, but it does avoid use of the stash command at all, which I find good for my own safety (because it reduces cognitive load). And it scales obviously to making multiple commits onto the temporary branch, etc.
- eridius 10y agoOr even just branch, commit, rebase onto the desired branch.