Like many of us, I like to work on feature branches. Branch, commit-commit-commit, push, pull-request. It’s clean and easy.
But sometimes I forget a step and screw my workflow up. I get to the
end of a round of commits and realise I forgot to
git branch before
I started coding. Now all my work is on local
That’s fixable, but it’s a pain. You’ve probably been there, and there are two solutions:
origin/master, checkout the new branch and pop the stash.
git push origin master:feature, and hope that
origin/masterdoesn’t move forward before the feature gets merged.
The former’s a pain and the latter relies on luck. Neither is ideal.
Step forward Magit, the premium Emacs git
magit-branch-spinoff automatically puts you back where you
want to be. It checks out a new branch based on your current
master back to
origin/master1. So, so easy.
Unsurprisingly, it’s available from a
M-x near you, or from Magit’s
You won’t ben surprised to learn it’s a bit more flexible than that, if you need it to be. See the docs. ↩