3 ms·
Because 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 the
by Grue3 10y ago
Because 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.