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 master
.
That's fixable, but it's a pain. You've probably been there, and there are two solutions:
master
to origin/master
,
checkout the new branch and pop the stash.git push origin master:feature
, and hope that origin/master
doesn'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
client. magit-branch-spinoff
automatically puts you back where you
want to be. It checks out a new branch based on your current HEAD
, and
resets master
back to origin/master
docs. So, so easy.
Unsurprisingly, it's available from a M-x
near you, or from Magit's
branch menu.